]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.18] go/types, types2: fix overlap test for union termlist
authorRobert Griesemer <gri@golang.org>
Sat, 2 Apr 2022 00:02:28 +0000 (17:02 -0700)
committerCherry Mui <cherryyz@google.com>
Wed, 6 Apr 2022 16:37:43 +0000 (16:37 +0000)
commit2097b2d51b095296d20712f0b8b0b42a6f693f2e
tree99631c5cd5f59fe242fa2ca40188d919236b60cf
parentc9b9a010eb06e32e424dc8ffffcc37c8717ad03a
[release-branch.go1.18] go/types, types2: fix overlap test for union termlist

Per the spec, "the type sets of all non-interface terms must be
pairwise disjoint (the pairwise intersection of the type sets must
be empty)" in a union.

For the overlap test, the existing implementation casually mixed
syntactic union terms (which may have interface type) with type set
terms (which are normalized/expanded and must not have interface
type). As a consequence, in some cases the overlap test failed.

This change skips terms with interface types in the overlap test.

For this cherry-pick, also rename the files ending in issue51607.go
to issue51607.go2 because the 1.18 branch requires tests containing
generic features to end in .go2.

Fixes #52119.

Change-Id: I8ae9953db31f0a0428389c6a45a6696aa2450219
Reviewed-on: https://go-review.googlesource.com/c/go/+/397695
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/398154
src/cmd/compile/internal/types2/testdata/examples/constraints.go2
src/cmd/compile/internal/types2/testdata/fixedbugs/issue51607.go2 [new file with mode: 0644]
src/cmd/compile/internal/types2/union.go
src/go/types/testdata/examples/constraints.go2
src/go/types/union.go