stencil.go (go1.19.src) | : | stencil.go (go1.19.1.src) | ||
---|---|---|---|---|
skipping to change at line 337 | skipping to change at line 337 | |||
} | } | |||
if rcvrValue == nil { | if rcvrValue == nil { | |||
fmt.Printf("%s in %v for generic function value % v\n", dictkind, outer, inst.X) | fmt.Printf("%s in %v for generic function value % v\n", dictkind, outer, inst.X) | |||
} else { | } else { | |||
fmt.Printf("%s in %v for generic method value %v\ n", dictkind, outer, inst.X) | fmt.Printf("%s in %v for generic method value %v\ n", dictkind, outer, inst.X) | |||
} | } | |||
} | } | |||
} else { // ir.OMETHEXPR or ir.METHVALUE | } else { // ir.OMETHEXPR or ir.METHVALUE | |||
// Method expression T.M where T is a generic type. | // Method expression T.M where T is a generic type. | |||
se := x.(*ir.SelectorExpr) | se := x.(*ir.SelectorExpr) | |||
targs := deref(se.X.Type()).RParams() | ||||
if len(targs) == 0 { | ||||
panic("bad") | ||||
} | ||||
if x.Op() == ir.OMETHVALUE { | if x.Op() == ir.OMETHVALUE { | |||
rcvrValue = se.X | rcvrValue = se.X | |||
} | } | |||
// se.X.Type() is the top-level type of the method expression. To | // se.X.Type() is the top-level type of the method expression. To | |||
// correctly handle method expressions involving embedded fields, | // correctly handle method expressions involving embedded fields, | |||
// look up the generic method below using the type of the receive r | // look up the generic method below using the type of the receive r | |||
// of se.Selection, since that will be the type that actually has | // of se.Selection, since that will be the type that actually has | |||
// the method. | // the method. | |||
recv := deref(se.Selection.Type.Recv().Type) | recv := deref(se.Selection.Type.Recv().Type) | |||
if len(recv.RParams()) == 0 { | targs := recv.RParams() | |||
if len(targs) == 0 { | ||||
// The embedded type that actually has the method is not | // The embedded type that actually has the method is not | |||
// actually generic, so no need to build a closure. | // actually generic, so no need to build a closure. | |||
return x | return x | |||
} | } | |||
baseType := recv.OrigType() | baseType := recv.OrigType() | |||
var gf *ir.Name | var gf *ir.Name | |||
for _, m := range baseType.Methods().Slice() { | for _, m := range baseType.Methods().Slice() { | |||
if se.Sel == m.Sym { | if se.Sel == m.Sym { | |||
gf = m.Nname.(*ir.Name) | gf = m.Nname.(*ir.Name) | |||
break | break | |||
End of changes. 2 change blocks. | ||||
5 lines changed or deleted | 2 lines changed or added |