]> Cypherpunks.ru repositories - gostls13.git/commit
[dev.typeparams] go/types: set type parameter indices when they are bound
authorRob Findley <rfindley@google.com>
Wed, 21 Jul 2021 14:21:23 +0000 (10:21 -0400)
committerRobert Findley <rfindley@google.com>
Thu, 22 Jul 2021 17:05:56 +0000 (17:05 +0000)
commit6f57139c7a6bc776f1335aca13d276d36343cf7c
tree12511df14bfa0466d590960980dcd86aa2bfddb5
parent311baf65f49f4b15396f7e88c05bc97d47f2e4ed
[dev.typeparams] go/types: set type parameter indices when they are bound

It is invalid to use a type parameter for more than one type, so we can
avoid passing the type parameter index to NewTypeParam and just set it
when type parameters are bound to a type via SetTParams or during type
checking.

In order to enforce the correctness of this change, introduce a
TypeParams type to represent a list of type parameters that have been
associated with a type. For now, expose this new type as the API for
type parameters, but this is of course not necessarily a final API.

Allowing *TypeParams to be nil also decreases the size of Named and
Signature, which is good as most instances of these types will not be
parameterized.

Change-Id: Ia1e39ba51edb05bb535eb5f41c34e9dd02d39c38
Reviewed-on: https://go-review.googlesource.com/c/go/+/336249
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
17 files changed:
src/go/types/api_test.go
src/go/types/assignments.go
src/go/types/builtins.go
src/go/types/call.go
src/go/types/decl.go
src/go/types/index.go
src/go/types/instance.go
src/go/types/instantiate.go
src/go/types/lookup.go
src/go/types/named.go
src/go/types/object.go
src/go/types/predicates.go
src/go/types/signature.go
src/go/types/sizeof_test.go
src/go/types/subst.go
src/go/types/typeparam.go
src/go/types/typestring.go