]> Cypherpunks repositories - gostls13.git/commit
go/types, types2: fix interface unification
authorRobert Griesemer <gri@golang.org>
Thu, 22 Jun 2023 23:40:46 +0000 (16:40 -0700)
committerGopher Robot <gobot@golang.org>
Mon, 26 Jun 2023 18:33:36 +0000 (18:33 +0000)
commitd49017a7c347e57830b87ebbbdbec087bfc1ca92
tree8c90f335e7b136594da14a3a4fce9a3088ac6bcd
parentb3ca8d2b3c78d36595c534de0ca604e7d3e37123
go/types, types2: fix interface unification

When unification of two types succeeds and at least one of them
is an interface, we must be more cautious about when to accept
the unification, to avoid order dependencies and unexpected
inference results.

The changes are localized and only affect matching against
interfaces; they further restrict what are valid unifications
(rather than allowing more code to pass). We may be able to
remove some of the restriotions in a future release.

See comments in code for a detailed description of the changes.

Also, factored out "asInterface" functionality into a function
to avoid needless repetition in the code.

Fixes #60933.
Fixes #60946.

Change-Id: I923f7a7c1a22e0f4fd29e441e016e7154429fc5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/505396
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/unify.go
src/go/types/unify.go
src/internal/types/testdata/fixedbugs/issue60933.go [new file with mode: 0644]
src/internal/types/testdata/fixedbugs/issue60946.go [new file with mode: 0644]