mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.typeparams] cmd/compile: fix use of method values with stenciled methods
We were handling the case where an OFUNCINST node was used as a function value, but not the case when an OFUNCINST node was used as a method value. In the case of a method value, we need to create a new selector expression that references the newly stenciled method. To make this work, also needed small fix to noder2 code to properly set the Sel of a method SelectorExpr (should be just the base method name, not the full method name including the type string). This has to be correct, so that the function created by MethodValueWrapper() can be typechecked successfully. Fixes #45817 Change-Id: I7343e8a0d35fc46b44dfe4d45b77997ba6c8733e Reviewed-on: https://go-review.googlesource.com/c/go/+/319589 Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com>
This commit is contained in:
parent
d2b3efcb90
commit
04f65d394c
4 changed files with 52 additions and 6 deletions
|
|
@ -266,7 +266,7 @@ func (g *irgen) selectorExpr(pos src.XPos, typ types2.Type, expr *syntax.Selecto
|
|||
recvType2 = recvType2Base
|
||||
// method is the generic method associated with the gen type
|
||||
method := g.obj(types2.AsNamed(recvType2).Method(last))
|
||||
n = ir.NewSelectorExpr(pos, ir.OCALLPART, x, method.Sym())
|
||||
n = ir.NewSelectorExpr(pos, ir.OCALLPART, x, typecheck.Lookup(expr.Sel.Value))
|
||||
n.(*ir.SelectorExpr).Selection = types.NewField(pos, method.Sym(), method.Type())
|
||||
n.(*ir.SelectorExpr).Selection.Nname = method
|
||||
typed(method.Type(), n)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue