diff options
author | Robert Griesemer <gri@golang.org> | 2021-08-23 21:04:56 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2021-08-24 16:36:59 +0000 |
commit | e6798795ff523b9b5df2514bffd8d5ce743c312e (patch) | |
tree | efad5a35171abae03abfc18c0753222814a9debd /src/cmd/compile/internal/types2 | |
parent | b1cdf860dd5f517a2835c6bd48d12dad29ade1da (diff) | |
download | go-e6798795ff523b9b5df2514bffd8d5ce743c312e.tar.gz go-e6798795ff523b9b5df2514bffd8d5ce743c312e.zip |
cmd/compile/internal/types2: use TypeList in the Inferred struct
This is a port of CL 343934 from go/types with the necessary
adjustments to the compiler.
Change-Id: I810144e6e2eb2bc8fa0d34dc206403c993cbbe7a
Reviewed-on: https://go-review.googlesource.com/c/go/+/344616
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2')
-rw-r--r-- | src/cmd/compile/internal/types2/api.go | 2 | ||||
-rw-r--r-- | src/cmd/compile/internal/types2/api_test.go | 9 | ||||
-rw-r--r-- | src/cmd/compile/internal/types2/check.go | 2 |
3 files changed, 7 insertions, 6 deletions
diff --git a/src/cmd/compile/internal/types2/api.go b/src/cmd/compile/internal/types2/api.go index f268508825..b2938b84da 100644 --- a/src/cmd/compile/internal/types2/api.go +++ b/src/cmd/compile/internal/types2/api.go @@ -373,7 +373,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 *TypeList Sig *Signature } diff --git a/src/cmd/compile/internal/types2/api_test.go b/src/cmd/compile/internal/types2/api_test.go index 269b06f08a..039a6c0e5e 100644 --- a/src/cmd/compile/internal/types2/api_test.go +++ b/src/cmd/compile/internal/types2/api_test.go @@ -500,7 +500,7 @@ func TestInferredInfo(t *testing.T) { } // look for inferred type arguments and signature - var targs []Type + var targs *TypeList var sig *Signature for call, inf := range info.Inferred { var fun syntax.Expr @@ -524,11 +524,12 @@ func TestInferredInfo(t *testing.T) { } // check that type arguments are correct - if len(targs) != len(test.targs) { - t.Errorf("package %s: got %d type arguments; want %d", name, len(targs), len(test.targs)) + if targs.Len() != len(test.targs) { + t.Errorf("package %s: got %d type arguments; want %d", name, targs.Len(), len(test.targs)) continue } - for i, targ := range targs { + for i := 0; i < targs.Len(); i++ { + targ := targs.At(i) if got := targ.String(); got != test.targs[i] { t.Errorf("package %s, %d. type argument: got %s; want %s", name, i, got, test.targs[i]) continue diff --git a/src/cmd/compile/internal/types2/check.go b/src/cmd/compile/internal/types2/check.go index 6bc965c497..4226b4de82 100644 --- a/src/cmd/compile/internal/types2/check.go +++ b/src/cmd/compile/internal/types2/check.go @@ -416,7 +416,7 @@ func (check *Checker) recordInferred(call syntax.Expr, targs []Type, sig *Signat assert(call != nil) assert(sig != nil) if m := check.Inferred; m != nil { - m[call] = Inferred{targs, sig} + m[call] = Inferred{NewTypeList(targs), sig} } } |