// the Fields to represent the receiver's method set.
if recv := fn.Type().Recv(); recv != nil {
typ := types.ReceiverBaseType(recv.Type)
- if typ.OrigSym != nil {
+ if typ.OrigSym() != nil {
// For a generic method, we mark the methods on the
// base generic type, since those are the methods
// that will be stenciled.
- typ = typ.OrigSym.Def.Type()
+ typ = typ.OrigSym().Def.Type()
}
meth := typecheck.Lookdot1(fn, typecheck.Lookup(decl.Name.Value), typ, typ.Methods(), 0)
meth.SetNointerface(true)
targs := deref(meth.Type().Recv().Type).RParams()
t := meth.X.Type()
- baseSym := deref(t).OrigSym
+ baseSym := deref(t).OrigSym()
baseType := baseSym.Def.(*ir.Name).Type()
var gf *ir.Name
for _, m := range baseType.Methods().Slice() {
// actually generic, so no need to build a closure.
return x
}
- baseType := recv.OrigSym.Def.Type()
+ baseType := recv.OrigSym().Def.Type()
var gf *ir.Name
for _, m := range baseType.Methods().Slice() {
if se.Sel == m.Sym {
typecheck.NeedRuntimeType(typ)
// Lookup the method on the base generic type, since methods may
// not be set on imported instantiated types.
- baseSym := typ.OrigSym
+ baseSym := typ.OrigSym()
baseType := baseSym.Def.(*ir.Name).Type()
for j, _ := range typ.Methods().Slice() {
if baseType.Methods().Slice()[j].Nointerface() {
// instantiated type, so we need a
// sub-dictionary.
targs := recvType.RParams()
- genRecvType := recvType.OrigSym.Def.Type()
+ genRecvType := recvType.OrigSym().Def.Type()
nameNode = typecheck.Lookdot1(call.X, se.Sel, genRecvType, genRecvType.Methods(), 1).Nname.(*ir.Name)
sym = g.getDictionarySym(nameNode, targs, true)
} else {
//fmt.Printf("Saw new type %v %v\n", instName, ntyp.HasTParam())
// Save the symbol for the base generic type.
- ntyp.OrigSym = g.pkg(typ.Obj().Pkg()).Lookup(typ.Obj().Name())
+ ntyp.SetOrigSym(g.pkg(typ.Obj().Pkg()).Lookup(typ.Obj().Name()))
ntyp.SetUnderlying(g.typ1(typ.Underlying()))
if typ.NumMethods() != 0 {
// Save a delayed call to g.fillinMethods() (once
// for export), so its methods will be available for inlining if needed.
func (p *crawler) checkGenericType(t *types.Type) {
if t != nil && t.HasTParam() {
- if t.OrigSym != nil {
+ if t.OrigSym() != nil {
// Convert to the base generic type.
- t = t.OrigSym.Def.Type()
+ t = t.OrigSym().Def.Type()
}
p.markType(t)
}
func (w *exportWriter) doTyp(t *types.Type) {
s := t.Sym()
- if s != nil && t.OrigSym != nil {
+ if s != nil && t.OrigSym() != nil {
assert(base.Flag.G > 0)
// This is an instantiated type - could be a re-instantiation like
// Value[T2] or a full instantiation like Value[int].
// types or existing typeparams from the function/method header.
w.typeList(t.RParams())
// Export a reference to the base type.
- baseType := t.OrigSym.Def.(*ir.Name).Type()
+ baseType := t.OrigSym().Def.(*ir.Name).Type()
w.typ(baseType)
return
}
// No need to calc sizes for re-instantiated generic types, and
// they are not necessarily resolved until the top-level type is
// defined (because of recursive types).
- if t.OrigSym == nil || !t.HasTParam() {
+ if t.OrigSym() == nil || !t.HasTParam() {
types.CheckSize(t)
}
p.typCache[off] = t
} else {
genType := types.ReceiverBaseType(n1.X.Type())
if genType.IsInstantiatedGeneric() {
- genType = genType.OrigSym.Def.Type()
+ genType = genType.OrigSym().Def.Type()
}
m = Lookdot1(n1, sel, genType, genType.Methods(), 1)
}
t := NewIncompleteNamedType(baseType.Pos(), instSym)
t.SetRParams(targs)
- t.OrigSym = baseSym
+ t.SetOrigSym(baseSym)
// baseType may still be TFORW or its methods may not be fully filled in
// (since we are in the middle of importing it). So, delay call to
for len(deferredInstStack) > 0 {
t := deferredInstStack[0]
deferredInstStack = deferredInstStack[1:]
- substInstType(t, t.OrigSym.Def.(*ir.Name).Type(), t.RParams())
+ substInstType(t, t.OrigSym().Def.(*ir.Name).Type(), t.RParams())
}
}
deferInst--
// during a type substitution for an instantiation. This is needed for
// instantiations of mutually recursive types.
func doInst(t *types.Type) *types.Type {
- return Instantiate(t.Pos(), t.OrigSym.Def.(*ir.Name).Type(), t.RParams())
+ return Instantiate(t.Pos(), t.OrigSym().Def.(*ir.Name).Type(), t.RParams())
}
// substInstType completes the instantiation of a generic type by doing a
forw.SetRParams(neededTargs)
// Copy the OrigSym from the re-instantiated type (which is the sym of
// the base generic type).
- assert(t.OrigSym != nil)
- forw.OrigSym = t.OrigSym
+ assert(t.OrigSym() != nil)
+ forw.SetOrigSym(t.OrigSym())
}
var newt *types.Type
// For an instantiated generic type, the symbol for the base generic type.
// This backpointer is useful, because the base type is the type that has
// the method bodies.
- OrigSym *Sym
+ origSym *Sym
}
func (*Type) CanBeAnSSAAux() {}
// OrigSym returns the name of the original generic type that t is an
// instantiation of, if any.
-func (t *Type) OrigSym_() *Sym { return t.OrigSym }
-func (t *Type) SetOrigSym(sym *Sym) { t.OrigSym = sym }
+func (t *Type) OrigSym() *Sym { return t.origSym }
+func (t *Type) SetOrigSym(sym *Sym) { t.origSym = sym }
// Underlying returns the underlying type of type t.
func (t *Type) Underlying() *Type { return t.underlying }