diff options
| author | Cuong Manh Le <cuong.manhle.vn@gmail.com> | 2021-09-09 01:11:26 +0700 |
|---|---|---|
| committer | Cuong Manh Le <cuong.manhle.vn@gmail.com> | 2021-09-09 03:31:51 +0000 |
| commit | 2481f6e367a56207b6c873180e0db9bc4f2b6365 (patch) | |
| tree | b3ad5c6f8a31d72402246a5857e3bc9f5275fe9e /src/cmd/compile/internal/noder/expr.go | |
| parent | d62866ef793872779c9011161e51b9c805fcb73d (diff) | |
| download | go-2481f6e367a56207b6c873180e0db9bc4f2b6365.tar.xz | |
cmd/compile: fix wrong instantiated type for embedded receiver
In case of embedded field, if the receiver was fully instantiated, we
must use its instantiated type, instead of passing the type params of
the base receiver.
Fixes #47797
Fixes #48253
Change-Id: I97613e7e669a72605137e82406f7bf5fbb629378
Reviewed-on: https://go-review.googlesource.com/c/go/+/348549
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Diffstat (limited to 'src/cmd/compile/internal/noder/expr.go')
| -rw-r--r-- | src/cmd/compile/internal/noder/expr.go | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/cmd/compile/internal/noder/expr.go b/src/cmd/compile/internal/noder/expr.go index 5eeafddae2..045f028e1a 100644 --- a/src/cmd/compile/internal/noder/expr.go +++ b/src/cmd/compile/internal/noder/expr.go @@ -360,12 +360,10 @@ func (g *irgen) selectorExpr(pos src.XPos, typ types2.Type, expr *syntax.Selecto n.(*ir.SelectorExpr).Selection.Nname = method typed(method.Type(), n) - // selinfo.Targs() are the types used to - // instantiate the type of receiver - targs2 := getTargs(selinfo) - targs := make([]ir.Node, targs2.Len()) + xt := deref(x.Type()) + targs := make([]ir.Node, len(xt.RParams())) for i := range targs { - targs[i] = ir.TypeNode(g.typ(targs2.At(i))) + targs[i] = ir.TypeNode(xt.RParams()[i]) } // Create function instantiation with the type @@ -388,16 +386,6 @@ func (g *irgen) selectorExpr(pos src.XPos, typ types2.Type, expr *syntax.Selecto return n } -// getTargs gets the targs associated with the receiver of a selected method -func getTargs(selinfo *types2.Selection) *types2.TypeList { - r := deref2(selinfo.Recv()) - n := types2.AsNamed(r) - if n == nil { - base.Fatalf("Incorrect type for selinfo %v", selinfo) - } - return n.TypeArgs() -} - func (g *irgen) exprList(expr syntax.Expr) []ir.Node { return g.exprs(unpackListExpr(expr)) } |
