]> Cypherpunks.ru repositories - gostls13.git/commit
go/types: use Identical to verify type identity in the Context map
authorRobert Findley <rfindley@google.com>
Wed, 10 Nov 2021 02:39:53 +0000 (21:39 -0500)
committerRobert Findley <rfindley@google.com>
Fri, 12 Nov 2021 18:10:48 +0000 (18:10 +0000)
commit0c6a6cd4d8c19ca8892085a38477e5ff56b7cc2b
tree8813b9fc2be30a1fb365408b88443b378b73f8c0
parent95d06576702c54139796f3e24e2eec4b135b1a09
go/types: use Identical to verify type identity in the Context map

We don't have guarantees that our type hash is perfect, and in fact
fuzzing found cases where identical types hashed to different values. In
case non-identical types hash to the same value, we should ensure that
we de-duplicate using Identical.

Adjust the type map to keep a slice of distinct type identities, so that
we can guarantee that type identity is preserved by de-duplication.

To allow look-up of instances by their identity, before they are
actually instantiated, add a Context.lookup method that accepts origin
type and type arguments. Replace the multi-function typeForHash method
with an update method that requires its argument be non-nil.

Change-Id: I8fe6fb2955f508db608161b7285b02d0a2fa0e46
Reviewed-on: https://go-review.googlesource.com/c/go/+/362798
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>
src/go/types/context.go
src/go/types/instantiate.go
src/go/types/named.go
src/go/types/predicates.go
src/go/types/subst.go
src/go/types/typexpr.go