[dev.typeparams] cmd/compile: rename (types2.Inferred.)Targs to TArgs

This is consistent with Named.TArgs.

This is a straight-forward port of https://golang.org/cl/321289
plus the necessary compiler noder changes.

Change-Id: I50791e5abe0d7f294293bed65cebc8dde8bf8c06
Reviewed-on: https://go-review.googlesource.com/c/go/+/325010
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Robert Griesemer 2021-06-03 21:58:32 -07:00
parent 692399fbaa
commit 246a5570be
4 changed files with 10 additions and 10 deletions

View file

@ -111,11 +111,11 @@ func (g *irgen) expr0(typ types2.Type, expr syntax.Expr) ir.Node {
// The key for the Inferred map is the CallExpr (if inferring // The key for the Inferred map is the CallExpr (if inferring
// types required the function arguments) or the IndexExpr below // types required the function arguments) or the IndexExpr below
// (if types could be inferred without the function arguments). // (if types could be inferred without the function arguments).
if inferred, ok := g.info.Inferred[expr]; ok && len(inferred.Targs) > 0 { if inferred, ok := g.info.Inferred[expr]; ok && len(inferred.TArgs) > 0 {
// This is the case where inferring types required the // This is the case where inferring types required the
// types of the function arguments. // types of the function arguments.
targs := make([]ir.Node, len(inferred.Targs)) targs := make([]ir.Node, len(inferred.TArgs))
for i, targ := range inferred.Targs { for i, targ := range inferred.TArgs {
targs[i] = ir.TypeNode(g.typ(targ)) targs[i] = ir.TypeNode(g.typ(targ))
} }
if fun.Op() == ir.OFUNCINST { if fun.Op() == ir.OFUNCINST {
@ -137,12 +137,12 @@ func (g *irgen) expr0(typ types2.Type, expr syntax.Expr) ir.Node {
case *syntax.IndexExpr: case *syntax.IndexExpr:
var targs []ir.Node var targs []ir.Node
if inferred, ok := g.info.Inferred[expr]; ok && len(inferred.Targs) > 0 { if inferred, ok := g.info.Inferred[expr]; ok && len(inferred.TArgs) > 0 {
// This is the partial type inference case where the types // This is the partial type inference case where the types
// can be inferred from other type arguments without using // can be inferred from other type arguments without using
// the types of the function arguments. // the types of the function arguments.
targs = make([]ir.Node, len(inferred.Targs)) targs = make([]ir.Node, len(inferred.TArgs))
for i, targ := range inferred.Targs { for i, targ := range inferred.TArgs {
targs[i] = ir.TypeNode(g.typ(targ)) targs[i] = ir.TypeNode(g.typ(targ))
} }
} else if _, ok := expr.Index.(*syntax.ListExpr); ok { } else if _, ok := expr.Index.(*syntax.ListExpr); ok {

View file

@ -361,7 +361,7 @@ func (tv TypeAndValue) HasOk() bool {
// Inferred reports the inferred type arguments and signature // Inferred reports the inferred type arguments and signature
// for a parameterized function call that uses type inference. // for a parameterized function call that uses type inference.
type Inferred struct { type Inferred struct {
Targs []Type TArgs []Type
Sig *Signature Sig *Signature
} }

View file

@ -514,7 +514,7 @@ func TestInferredInfo(t *testing.T) {
panic(fmt.Sprintf("unexpected call expression type %T", call)) panic(fmt.Sprintf("unexpected call expression type %T", call))
} }
if syntax.String(fun) == test.fun { if syntax.String(fun) == test.fun {
targs = inf.Targs targs = inf.TArgs
sig = inf.Sig sig = inf.Sig
break break
} }

View file

@ -26,9 +26,9 @@ func sanitizeInfo(info *Info) {
for e, inf := range info.Inferred { for e, inf := range info.Inferred {
changed := false changed := false
for i, targ := range inf.Targs { for i, targ := range inf.TArgs {
if typ := s.typ(targ); typ != targ { if typ := s.typ(targ); typ != targ {
inf.Targs[i] = typ inf.TArgs[i] = typ
changed = true changed = true
} }
} }