}
t.SetUnderlying(subst.Typ(baseType.Underlying()))
- if t.HasShape() && !t.IsInterface() {
- // Concrete shape types have no methods.
- return
- }
-
newfields := make([]*types.Field, baseType.Methods().Len())
for i, f := range baseType.Methods().Slice() {
if !f.IsMethod() || types.IsInterfaceMethod(f.Type) {
}
t2 := msubst.Typ(f.Type)
oldsym := f.Nname.Sym()
- newsym := MakeFuncInstSym(oldsym, targs, true)
+ newsym := MakeFuncInstSym(oldsym, targs, true, true)
var nname *ir.Name
if newsym.Def != nil {
nname = newsym.Def.(*ir.Name)
}
// MakeFuncInstSym makes the unique sym for a stenciled generic function or method,
-// based on the name of the function fnsym and the targs. It replaces any
-// existing bracket type list in the name. MakeInstName asserts that fnsym has
+// based on the name of the function gf and the targs. It replaces any
+// existing bracket type list in the name. MakeInstName asserts that gf has
// brackets in its name if and only if hasBrackets is true.
//
// Names of declared generic functions have no brackets originally, so hasBrackets
//
// The standard naming is something like: 'genFn[int,bool]' for functions and
// '(*genType[int,bool]).methodName' for methods
-func MakeFuncInstSym(gf *types.Sym, targs []*types.Type, hasBrackets bool) *types.Sym {
- return gf.Pkg.Lookup(makeInstName1(gf.Name, targs, hasBrackets))
+//
+// isMethodNode specifies if the name of a method node is being generated (as opposed
+// to a name of an instantiation of generic function or name of the shape-based
+// function that helps implement a method of an instantiated type). For method nodes
+// on shape types, we prepend "nofunc.", because method nodes for shape types will
+// have no body, and we want to avoid a name conflict with the shape-based function
+// that helps implement the same method for fully-instantiated types.
+func MakeFuncInstSym(gf *types.Sym, targs []*types.Type, isMethodNode, hasBrackets bool) *types.Sym {
+ nm := makeInstName1(gf.Name, targs, hasBrackets)
+ if targs[0].HasShape() && isMethodNode {
+ nm = "nofunc." + nm
+ }
+ return gf.Pkg.Lookup(nm)
}
func MakeDictSym(gf *types.Sym, targs []*types.Type, hasBrackets bool) *types.Sym {
for i, f := range t.Methods().Slice() {
t2 := ts.typ1(f.Type)
oldsym := f.Nname.Sym()
- newsym := MakeFuncInstSym(oldsym, ts.Targs, true)
+ newsym := MakeFuncInstSym(oldsym, ts.Targs, true, true)
var nname *ir.Name
if newsym.Def != nil {
nname = newsym.Def.(*ir.Name)