aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/predicates.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-07-11 15:27:49 -0700
committerRobert Griesemer <gri@golang.org>2021-07-14 23:33:49 +0000
commitdd8bdf4a1fceb06231eb73c026f4a7fe41f00dc1 (patch)
treefd2c1b9aaea38d58cff4817d3b6107c455a9e4ec /src/cmd/compile/internal/types2/predicates.go
parent2a8087817c18314d81c4165258487cdba73ebc71 (diff)
downloadgo-dd8bdf4a1fceb06231eb73c026f4a7fe41f00dc1.tar.gz
go-dd8bdf4a1fceb06231eb73c026f4a7fe41f00dc1.zip
[dev.typeparams] cmd/compile/internal/types2: interface identity must consider full type set
There is no (obvious) way to test this at the moment because we don't permit such constraint interfaces as ordinary types. Change-Id: Ieeec023ed82a2c71ed50d111f26916aba4a59099 Reviewed-on: https://go-review.googlesource.com/c/go/+/333889 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/predicates.go')
-rw-r--r--src/cmd/compile/internal/types2/predicates.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/types2/predicates.go b/src/cmd/compile/internal/types2/predicates.go
index 2f10898585..e862c0fca8 100644
--- a/src/cmd/compile/internal/types2/predicates.go
+++ b/src/cmd/compile/internal/types2/predicates.go
@@ -270,12 +270,21 @@ func identical(x, y Type, cmpTags bool, p *ifacePair) bool {
}
case *Interface:
+ // Two interface types are identical if they describe the same type sets.
+ // With the existing implementation restriction, this simplifies to:
+ //
// Two interface types are identical if they have the same set of methods with
- // the same names and identical function types. Lower-case method names from
- // different packages are always different. The order of the methods is irrelevant.
+ // the same names and identical function types, and if any type restrictions
+ // are the same. Lower-case method names from different packages are always
+ // different. The order of the methods is irrelevant.
if y, ok := y.(*Interface); ok {
- a := x.typeSet().methods
- b := y.typeSet().methods
+ xset := x.typeSet()
+ yset := y.typeSet()
+ if !Identical(xset.types, yset.types) {
+ return false
+ }
+ a := xset.methods
+ b := yset.methods
if len(a) == len(b) {
// Interface types are the only types where cycles can occur
// that are not "terminated" via named types; and such cycles