]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] cmd/compile: rename (types2.Inferred.)Targs to TArgs
authorRobert Griesemer <gri@golang.org>
Fri, 4 Jun 2021 04:58:32 +0000 (21:58 -0700)
committerRobert Griesemer <gri@golang.org>
Sat, 5 Jun 2021 01:52:30 +0000 (01:52 +0000)
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>
src/cmd/compile/internal/noder/expr.go
src/cmd/compile/internal/types2/api.go
src/cmd/compile/internal/types2/api_test.go
src/cmd/compile/internal/types2/sanitize.go

index d6c75845ce5eadf61a066cde70f656f8ca5381da..7034a19b8151b29e88ef9bf9a26868c89a3f92dc 100644 (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
                // types required the function arguments) or the IndexExpr below
                // (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
                        // types of the function arguments.
-                       targs := make([]ir.Node, len(inferred.Targs))
-                       for i, targ := range inferred.Targs {
+                       targs := make([]ir.Node, len(inferred.TArgs))
+                       for i, targ := range inferred.TArgs {
                                targs[i] = ir.TypeNode(g.typ(targ))
                        }
                        if fun.Op() == ir.OFUNCINST {
@@ -137,12 +137,12 @@ func (g *irgen) expr0(typ types2.Type, expr syntax.Expr) ir.Node {
        case *syntax.IndexExpr:
                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
                        // can be inferred from other type arguments without using
                        // the types of the function arguments.
-                       targs = make([]ir.Node, len(inferred.Targs))
-                       for i, targ := range inferred.Targs {
+                       targs = make([]ir.Node, len(inferred.TArgs))
+                       for i, targ := range inferred.TArgs {
                                targs[i] = ir.TypeNode(g.typ(targ))
                        }
                } else if _, ok := expr.Index.(*syntax.ListExpr); ok {
index 433250f02c8d92345faef6867730413f0bc25a70..4f7f35e61b2e5fb8ccc4ac4c581b567088714047 100644 (file)
@@ -361,7 +361,7 @@ func (tv TypeAndValue) HasOk() bool {
 // Inferred reports the inferred type arguments and signature
 // for a parameterized function call that uses type inference.
 type Inferred struct {
-       Targs []Type
+       TArgs []Type
        Sig   *Signature
 }
 
index 49d710067a8116428235cc7e8d1c7a52b7ebcad8..c7f3e490aa0aaaf48b1ed69c3a5d13b76d996334 100644 (file)
@@ -514,7 +514,7 @@ func TestInferredInfo(t *testing.T) {
                                panic(fmt.Sprintf("unexpected call expression type %T", call))
                        }
                        if syntax.String(fun) == test.fun {
-                               targs = inf.Targs
+                               targs = inf.TArgs
                                sig = inf.Sig
                                break
                        }
index 4e654e074fcceb6aa0caaed7159f3299b37d90ef..406b46e574c6392388f338355124eba792b82f75 100644 (file)
@@ -26,9 +26,9 @@ func sanitizeInfo(info *Info) {
 
        for e, inf := range info.Inferred {
                changed := false
-               for i, targ := range inf.Targs {
+               for i, targ := range inf.TArgs {
                        if typ := s.typ(targ); typ != targ {
-                               inf.Targs[i] = typ
+                               inf.TArgs[i] = typ
                                changed = true
                        }
                }