</li>
<li>
The new type
- <a href="/pkg/go/types/#TypeList"><code>TypeList</code></a> and factory function
- <a href="/pkg/go/types/#NewTypeList"><code>NewTypeList</code></a> facilitate storing
- a list of types.
+ <a href="/pkg/go/types/#TypeList"><code>TypeList</code></a> holds a list of types.
</li>
<li>
The new factory function
assert(ident != nil)
assert(typ != nil)
if m := check.Instances; m != nil {
- m[ident] = Instance{NewTypeList(targs), typ}
+ m[ident] = Instance{newTypeList(targs), typ}
}
}
case *Named:
tname := NewTypeName(pos, orig.obj.pkg, orig.obj.name, nil)
named := check.newNamed(tname, orig, nil, nil, nil) // underlying, tparams, and methods are set when named is resolved
- named.targs = NewTypeList(targs)
+ named.targs = newTypeList(targs)
named.resolver = func(ctxt *Context, n *Named) (*TypeParamList, Type, []*Func) {
return expandNamed(ctxt, n, pos)
}
// TypeList holds a list of types.
type TypeList struct{ types []Type }
-// NewTypeList returns a new TypeList with the types in list.
-func NewTypeList(list []Type) *TypeList {
+// newTypeList returns a new TypeList with the types in list.
+func newTypeList(list []Type) *TypeList {
if len(list) == 0 {
return nil
}
if inst == nil {
tname := NewTypeName(x.Pos(), orig.obj.pkg, orig.obj.name, nil)
inst = check.newNamed(tname, orig, nil, nil, nil) // underlying, methods and tparams are set when named is resolved
- inst.targs = NewTypeList(targs)
+ inst.targs = newTypeList(targs)
inst = ctxt.update(h, orig, targs, inst).(*Named)
}
def.setUnderlying(inst)
// be set to Typ[Invalid] in expandNamed.
inferred = check.infer(x.Pos(), tparams, targs, nil, nil)
if len(inferred) > len(targs) {
- inst.targs = NewTypeList(inferred)
+ inst.targs = newTypeList(inferred)
}
}
assert(ident != nil)
assert(typ != nil)
if m := check.Instances; m != nil {
- m[ident] = Instance{NewTypeList(targs), typ}
+ m[ident] = Instance{newTypeList(targs), typ}
}
}
case *Named:
tname := NewTypeName(pos, orig.obj.pkg, orig.obj.name, nil)
named := check.newNamed(tname, orig, nil, nil, nil) // underlying, tparams, and methods are set when named is resolved
- named.targs = NewTypeList(targs)
+ named.targs = newTypeList(targs)
named.resolver = func(ctxt *Context, n *Named) (*TypeParamList, Type, []*Func) {
return expandNamed(ctxt, n, pos)
}
// TypeList holds a list of types.
type TypeList struct{ types []Type }
-// NewTypeList returns a new TypeList with the types in list.
-func NewTypeList(list []Type) *TypeList {
+// newTypeList returns a new TypeList with the types in list.
+func newTypeList(list []Type) *TypeList {
if len(list) == 0 {
return nil
}
if inst == nil {
tname := NewTypeName(ix.X.Pos(), orig.obj.pkg, orig.obj.name, nil)
inst = check.newNamed(tname, orig, nil, nil, nil) // underlying, methods and tparams are set when named is resolved
- inst.targs = NewTypeList(targs)
+ inst.targs = newTypeList(targs)
inst = ctxt.update(h, orig, targs, inst).(*Named)
}
def.setUnderlying(inst)
// be set to Typ[Invalid] in expandNamed.
inferred = check.infer(ix.Orig, tparams, targs, nil, nil)
if len(inferred) > len(targs) {
- inst.targs = NewTypeList(inferred)
+ inst.targs = newTypeList(inferred)
}
}