mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: relax overly strict assertion
The assertion here was to make sure the newly constructed and typechecked expression selected the same receiver-qualified method, but in the case of anonymous receiver types we can actually end up with separate types.Field instances corresponding to each types.Type instance. In that case, the assertion spuriously failed. The fix here is to relax and assertion and just compare the method's name and type (including receiver type). Fixes #58563. Change-Id: I67d51ddb020e6ed52671473c93fc08f283a40886 Reviewed-on: https://go-review.googlesource.com/c/go/+/471676 Auto-Submit: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
70efe9f721
commit
37a2004b43
4 changed files with 48 additions and 1 deletions
|
|
@ -2184,7 +2184,18 @@ func (r *reader) expr() (res ir.Node) {
|
|||
}
|
||||
|
||||
n := typecheck.Expr(ir.NewSelectorExpr(pos, ir.OXDOT, recv, wrapperFn.Sel)).(*ir.SelectorExpr)
|
||||
assert(n.Selection == wrapperFn.Selection)
|
||||
|
||||
// As a consistency check here, we make sure "n" selected the
|
||||
// same method (represented by a types.Field) that wrapperFn
|
||||
// selected. However, for anonymous receiver types, there can be
|
||||
// multiple such types.Field instances (#58563). So we may need
|
||||
// to fallback to making sure Sym and Type (including the
|
||||
// receiver parameter's type) match.
|
||||
if n.Selection != wrapperFn.Selection {
|
||||
assert(n.Selection.Sym == wrapperFn.Selection.Sym)
|
||||
assert(types.Identical(n.Selection.Type, wrapperFn.Selection.Type))
|
||||
assert(types.Identical(n.Selection.Type.Recv().Type, wrapperFn.Selection.Type.Recv().Type))
|
||||
}
|
||||
|
||||
wrapper := methodValueWrapper{
|
||||
rcvr: n.X.Type(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue