diff options
author | Robert Griesemer <gri@golang.org> | 2021-08-23 20:43:57 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2021-08-24 16:36:55 +0000 |
commit | b1cdf860dd5f517a2835c6bd48d12dad29ade1da (patch) | |
tree | 571be229b1b45cee3d3c84111e99fe1e9b3d4265 /src/cmd/compile/internal/types2/unify.go | |
parent | 1ff0554b5318d5a39e2b26a9c84330e6aa47b1c6 (diff) | |
download | go-b1cdf860dd5f517a2835c6bd48d12dad29ade1da.tar.gz go-b1cdf860dd5f517a2835c6bd48d12dad29ade1da.zip |
cmd/compile/internal/types2: use a TypeList type to hold type arguments
This is a port of CL 343933 from go/types with the necessary
adjustments in the compiler.
With this CL type parameters and type lists are now held in
TParamList and TypeList data types which don't expose the
internal representation.
Change-Id: I6d60881b5db995dbc04ed3f4a96e8b5d41f83969
Reviewed-on: https://go-review.googlesource.com/c/go/+/344615
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/unify.go')
-rw-r--r-- | src/cmd/compile/internal/types2/unify.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/types2/unify.go b/src/cmd/compile/internal/types2/unify.go index 58f5c17e5f..d4fbebc11b 100644 --- a/src/cmd/compile/internal/types2/unify.go +++ b/src/cmd/compile/internal/types2/unify.go @@ -429,13 +429,17 @@ func (u *unifier) nify(x, y Type, p *ifacePair) bool { if y, ok := y.(*Named); ok { x.expand(nil) y.expand(nil) + + xargs := x.targs.list() + yargs := y.targs.list() + // TODO(gri) This is not always correct: two types may have the same names // in the same package if one of them is nested in a function. // Extremely unlikely but we need an always correct solution. if x.obj.pkg == y.obj.pkg && x.obj.name == y.obj.name { - assert(len(x.targs) == len(y.targs)) - for i, x := range x.targs { - if !u.nify(x, y.targs[i], p) { + assert(len(xargs) == len(yargs)) + for i, x := range xargs { + if !u.nify(x, yargs[i], p) { return false } } |