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/subst.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/subst.go')
-rw-r--r-- | src/cmd/compile/internal/types2/subst.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/types2/subst.go b/src/cmd/compile/internal/types2/subst.go index 467066cc69..918e5f3043 100644 --- a/src/cmd/compile/internal/types2/subst.go +++ b/src/cmd/compile/internal/types2/subst.go @@ -188,21 +188,21 @@ func (subst *subster) typ(typ Type) Type { } var newTArgs []Type - assert(len(t.targs) == t.TParams().Len()) + assert(t.targs.Len() == t.TParams().Len()) // already instantiated dump(">>> %s already instantiated", t) // For each (existing) type argument targ, determine if it needs // to be substituted; i.e., if it is or contains a type parameter // that has a type argument for it. - for i, targ := range t.targs { + for i, targ := range t.targs.list() { dump(">>> %d targ = %s", i, targ) new_targ := subst.typ(targ) if new_targ != targ { dump(">>> substituted %d targ %s => %s", i, targ, new_targ) if newTArgs == nil { newTArgs = make([]Type, t.TParams().Len()) - copy(newTArgs, t.targs) + copy(newTArgs, t.targs.list()) } newTArgs[i] = new_targ } @@ -230,7 +230,7 @@ func (subst *subster) typ(typ Type) Type { // It's ok to provide a nil *Checker because the newly created type // doesn't need to be (lazily) expanded; it's expanded below. named := (*Checker)(nil).newNamed(tname, t.orig, nil, t.tparams, t.methods) // t is loaded, so tparams and methods are available - named.targs = newTArgs + named.targs = NewTypeList(newTArgs) subst.typMap[h] = named t.expand(subst.typMap) // must happen after typMap update to avoid infinite recursion |