cmd/compile: change ir.InstExpr.Targs from Node to Ntype

Type arguments are always type expressions, which are semantically
represented by Ntype.

In fact, the slice should probably just be []*types.Type instead, and
that would remove a lot of ir.TypeNode wrapping/unwrapping. But this
lead to issues within the stenciling code, and I can't immediately
make sense why.

Change-Id: Ib944db30e4d21284bc2d8d954b68ecb70b4205a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/403843
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Matthew Dempsky 2022-05-03 12:51:25 -07:00
parent 025a9c3438
commit 3abe8fe00b
7 changed files with 37 additions and 17 deletions

View file

@ -197,7 +197,7 @@ func (g *irgen) expr0(typ types2.Type, expr syntax.Expr) ir.Node {
// substType does a normal type substition, but tparams is in the form of a field
// list, and targs is in terms of a slice of type nodes. substType records any newly
// instantiated types into g.instTypeList.
func (g *irgen) substType(typ *types.Type, tparams *types.Type, targs []ir.Node) *types.Type {
func (g *irgen) substType(typ *types.Type, tparams *types.Type, targs []ir.Ntype) *types.Type {
fields := tparams.FieldSlice()
tparams1 := make([]*types.Type, len(fields))
for i, f := range fields {
@ -339,7 +339,7 @@ func (g *irgen) selectorExpr(pos src.XPos, typ types2.Type, expr *syntax.Selecto
typed(method.Type(), n)
xt := deref(x.Type())
targs := make([]ir.Node, len(xt.RParams()))
targs := make([]ir.Ntype, len(xt.RParams()))
for i := range targs {
targs[i] = ir.TypeNode(xt.RParams()[i])
}