mirror of
https://github.com/golang/go.git
synced 2025-11-01 01:00:56 +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
|
|
@ -494,8 +494,13 @@ func NewNameOffsetExpr(pos src.XPos, name *Name, offset int64, typ *types.Type)
|
|||
// A SelectorExpr is a selector expression X.Sel.
|
||||
type SelectorExpr struct {
|
||||
miniExpr
|
||||
X Node
|
||||
Sel *types.Sym
|
||||
X Node
|
||||
// Sel is the name of the field or method being selected, without (in the
|
||||
// case of methods) any preceding type specifier. If the field/method is
|
||||
// exported, than the Sym uses the local package regardless of the package
|
||||
// of the containing type.
|
||||
Sel *types.Sym
|
||||
// The actual selected field - may not be filled in until typechecking.
|
||||
Selection *types.Field
|
||||
Prealloc *Name // preallocated storage for OCALLPART, if any
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue