mirror of
https://github.com/golang/go
synced 2024-10-06 08:00:07 +00:00
[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:
parent
692399fbaa
commit
246a5570be
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue