// this types2-to-types1 translation.
return sym.Def.Type()
}
- tp := types.NewTypeParam(sym, typ.Index())
- nname := ir.NewDeclNameAt(g.pos(typ.Obj().Pos()), ir.OTYPE, sym)
- sym.Def = nname
- nname.SetType(tp)
- tp.SetNod(nname)
+ obj := ir.NewDeclNameAt(g.pos(typ.Obj().Pos()), ir.OTYPE, sym)
+ sym.Def = obj
+ tp := types.NewTypeParam(obj, typ.Index())
+ obj.SetType(tp)
// Set g.typs[typ] in case the bound methods reference typ.
g.typs[typ] = tp
// this types2-to-types1 translation.
return sym.Def.(*ir.Name)
}
+ n := importsym(pos, sym, ir.OTYPE, ir.PTYPEPARAM)
// The typeparam index is set at the point where the containing type
// param list is imported.
- t := types.NewTypeParam(sym, 0)
- // Nname needed to save the pos.
- nname := ir.NewDeclNameAt(pos, ir.OTYPE, sym)
- sym.Def = nname
- nname.SetType(t)
- t.SetNod(nname)
+ t := types.NewTypeParam(n, 0)
+ n.SetType(t)
implicit := false
if r.p.exportVersion >= iexportVersionGo1_18 {
implicit = r.bool()
bound.MarkImplicit()
}
t.SetBound(bound)
- return nname
+ return n
case 'V':
typ := r.typ()
func (t *Type) Kind() Kind { return t.kind }
// Sym returns the name of type t.
-func (t *Type) Sym() *Sym { return t.sym }
-func (t *Type) SetSym(sym *Sym) { t.sym = sym }
+func (t *Type) Sym() *Sym { return t.sym }
// OrigType returns the original generic type that t is an
// instantiation of, if any.
// Underlying returns the underlying type of type t.
func (t *Type) Underlying() *Type { return t.underlying }
-// SetNod associates t with syntax node n.
-func (t *Type) SetNod(n Object) {
- // t.nod can be non-nil already
- // in the case of shared *Types, like []byte or interface{}.
- if t.nod == nil {
- t.nod = n
- }
-}
-
// Pos returns a position associated with t, if any.
// This should only be used for diagnostics.
func (t *Type) Pos() src.XPos {
// NewTypeParam returns a new type param with the specified sym (package and name)
// and specified index within the typeparam list.
-func NewTypeParam(sym *Sym, index int) *Type {
+func NewTypeParam(obj Object, index int) *Type {
t := newType(TTYPEPARAM)
- t.sym = sym
+ t.sym = obj.Sym()
+ t.nod = obj
t.extra.(*Typeparam).index = index
t.SetHasTParam(true)
return t