@@ -12,15 +12,15 @@ import (
12
12
// A Named represents a named (defined) type.
13
13
type Named struct {
14
14
check * Checker
15
- info typeInfo // for cycle detection
16
- obj * TypeName // corresponding declared object for declared types; placeholder for instantiated types
17
- orig * Named // original, uninstantiated type
18
- fromRHS Type // type (on RHS of declaration) this *Named type is derived of (for cycle reporting)
19
- underlying Type // possibly a *Named during setup; never a *Named once set up completely
20
- instPos * token.Pos // position information for lazy instantiation, or nil
21
- tparams * TParamList // type parameters, or nil
22
- targs * TypeList // type arguments (after instantiation), or nil
23
- methods []* Func // methods declared for this type (not the method set of this type); signatures are type-checked lazily
15
+ info typeInfo // for cycle detection
16
+ obj * TypeName // corresponding declared object for declared types; placeholder for instantiated types
17
+ orig * Named // original, uninstantiated type
18
+ fromRHS Type // type (on RHS of declaration) this *Named type is derived of (for cycle reporting)
19
+ underlying Type // possibly a *Named during setup; never a *Named once set up completely
20
+ instPos * token.Pos // position information for lazy instantiation, or nil
21
+ tparams * TypeParamList // type parameters, or nil
22
+ targs * TypeList // type arguments (after instantiation), or nil
23
+ methods []* Func // methods declared for this type (not the method set of this type); signatures are type-checked lazily
24
24
25
25
resolve func (* Named ) ([]* TypeParam , Type , []* Func )
26
26
once sync.Once
@@ -58,10 +58,10 @@ func (t *Named) load() *Named {
58
58
// (necessary because types2 expects the receiver type for methods
59
59
// on defined interface types to be the Named rather than the
60
60
// underlying Interface), maybe it should just handle calling
61
- // SetTParams , SetUnderlying, and AddMethod instead? Those
61
+ // SetTypeParams , SetUnderlying, and AddMethod instead? Those
62
62
// methods would need to support reentrant calls though. It would
63
63
// also make the API more future-proof towards further extensions
64
- // (like SetTParams ).
64
+ // (like SetTypeParams ).
65
65
66
66
tparams , underlying , methods := t .resolve (t )
67
67
@@ -78,7 +78,7 @@ func (t *Named) load() *Named {
78
78
}
79
79
80
80
// newNamed is like NewNamed but with a *Checker receiver and additional orig argument.
81
- func (check * Checker ) newNamed (obj * TypeName , orig * Named , underlying Type , tparams * TParamList , methods []* Func ) * Named {
81
+ func (check * Checker ) newNamed (obj * TypeName , orig * Named , underlying Type , tparams * TypeParamList , methods []* Func ) * Named {
82
82
typ := & Named {check : check , obj : obj , orig : orig , fromRHS : underlying , underlying : underlying , tparams : tparams , methods : methods }
83
83
if typ .orig == nil {
84
84
typ .orig = typ
@@ -119,15 +119,15 @@ func (t *Named) _Orig() *Named { return t.orig }
119
119
// TODO(gri) Come up with a better representation and API to distinguish
120
120
// between parameterized instantiated and non-instantiated types.
121
121
122
- // TParams returns the type parameters of the named type t, or nil.
122
+ // TypeParams returns the type parameters of the named type t, or nil.
123
123
// The result is non-nil for an (originally) parameterized type even if it is instantiated.
124
- func (t * Named ) TParams () * TParamList { return t .load ().tparams }
124
+ func (t * Named ) TypeParams () * TypeParamList { return t .load ().tparams }
125
125
126
- // SetTParams sets the type parameters of the named type t.
127
- func (t * Named ) SetTParams (tparams []* TypeParam ) { t .load ().tparams = bindTParams (tparams ) }
126
+ // SetTypeParams sets the type parameters of the named type t.
127
+ func (t * Named ) SetTypeParams (tparams []* TypeParam ) { t .load ().tparams = bindTParams (tparams ) }
128
128
129
- // TArgs returns the type arguments used to instantiate the named type t.
130
- func (t * Named ) TArgs () * TypeList { return t .targs }
129
+ // TypeArgs returns the type arguments used to instantiate the named type t.
130
+ func (t * Named ) TypeArgs () * TypeList { return t .targs }
131
131
132
132
// NumMethods returns the number of explicit methods whose receiver is named type t.
133
133
func (t * Named ) NumMethods () int { return len (t .load ().methods ) }
@@ -245,8 +245,8 @@ func (n *Named) setUnderlying(typ Type) {
245
245
func (n * Named ) expand (env * Environment ) * Named {
246
246
if n .instPos != nil {
247
247
// n must be loaded before instantiation, in order to have accurate
248
- // tparams. This is done implicitly by the call to n.TParams , but making it
249
- // explicit is harmless: load is idempotent.
248
+ // tparams. This is done implicitly by the call to n.TypeParams , but making
249
+ // it explicit is harmless: load is idempotent.
250
250
n .load ()
251
251
var u Type
252
252
if n .check .validateTArgLen (* n .instPos , n .tparams .Len (), n .targs .Len ()) {
@@ -268,7 +268,7 @@ func (n *Named) expand(env *Environment) *Named {
268
268
// shouldn't return that instance from expand.
269
269
env .typeForHash (h , n )
270
270
}
271
- u = n .check .subst (* n .instPos , n .orig .underlying , makeSubstMap (n .TParams ().list (), n .targs .list ()), env )
271
+ u = n .check .subst (* n .instPos , n .orig .underlying , makeSubstMap (n .TypeParams ().list (), n .targs .list ()), env )
272
272
} else {
273
273
u = Typ [Invalid ]
274
274
}
0 commit comments