]> Cypherpunks repositories - gostls13.git/commit
go/types, types2: make the new comparable semantics the default
authorRobert Griesemer <gri@golang.org>
Wed, 30 Nov 2022 22:19:39 +0000 (14:19 -0800)
committerGopher Robot <gobot@golang.org>
Thu, 1 Dec 2022 16:39:00 +0000 (16:39 +0000)
commit15e705ea963b5008112793507365e24b743606bc
tree7b8543c0e9f935d233416e69cc13d0a722b0cec2
parentc85848a4a62f839427bb56cb2772e008e405cf1f
go/types, types2: make the new comparable semantics the default

Ordinary interface types now satisfy comparable constraints.

This change makes the new comparable semantics the default behavior,
depending on the Go -lang version.

It also renames the flag types2.Config.AltComparableSemantics to
types2.Config.OldComparableSemantics and inverts its meaning
(or types.Config.oldComparableSemantics respectively).

Adjust some existing tests by setting -oldComparableSemantics
and add some new tests that verify version-dependent behavior.

The compiler flag -oldcomparable may be used to temporarily
switch back to the Go 1.18/1.19 behavior should this change
cause problems, or to identify that a problem is unrelated
to this change. The flag will be removed for Go 1.21.

For #52509.
For #56548.

Change-Id: Ic2b22db9433a8dd81dc1ed9d30835f0395fb7205
Reviewed-on: https://go-review.googlesource.com/c/go/+/453978
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
14 files changed:
src/cmd/compile/internal/base/flag.go
src/cmd/compile/internal/noder/irgen.go
src/cmd/compile/internal/types2/api.go
src/cmd/compile/internal/types2/check_test.go
src/cmd/compile/internal/types2/instantiate.go
src/go/types/api.go
src/go/types/check_test.go
src/go/types/instantiate.go
src/internal/types/testdata/check/issues1.go
src/internal/types/testdata/fixedbugs/issue50646.go
src/internal/types/testdata/fixedbugs/issue51257.go
src/internal/types/testdata/spec/comparable.go
src/internal/types/testdata/spec/comparable1.19.go [new file with mode: 0644]
src/internal/types/testdata/spec/oldcomparable.go [new file with mode: 0644]