]> Cypherpunks.ru repositories - gostls13.git/commit
go/types: externalize union type sets
authorRobert Findley <rfindley@google.com>
Tue, 14 Dec 2021 16:33:10 +0000 (11:33 -0500)
committerRobert Findley <rfindley@google.com>
Tue, 14 Dec 2021 23:18:22 +0000 (23:18 +0000)
commitaf05064f978729f3b066e1d627633c11c5e267e2
treefd31fb7dad7e2af449d671aaa5e0c1d95f226dd2
parent1540239f48f6beaa1cae6b34d00d74860366da7d
go/types: externalize union type sets

Move calculated type sets for unions into a map, rather than storing
them on the Union type.

Type sets for unions only matter during calculation of interface type
sets, and to a lesser extent inside of Identical. The latter should not
be encountered during type checking, as Identical uses the precomputed
interface type set when comparing interfaces, and unions do not arise
outside of interface types.

Removing the tset field from Union potentially frees up memory, and
eliminates a source of races via calls to NewUnion and Identical. It
also sets the stage for recording Unions for every subexpression of
union terms, which preserves an existing invariant that BinaryExprs and
UnaryExprs should have a recorded type.

Updates #50093

Change-Id: I5956fa59be6b0907c3a71faeba9fa5dd8aae0d65
Reviewed-on: https://go-review.googlesource.com/c/go/+/371756
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/go/types/check.go
src/go/types/predicates.go
src/go/types/sizeof_test.go
src/go/types/subst.go
src/go/types/typeset.go
src/go/types/union.go