]> Cypherpunks.ru repositories - gostls13.git/commit
go/types, types2: implement alternative comparable semantics
authorRobert Griesemer <gri@golang.org>
Wed, 19 Oct 2022 22:17:42 +0000 (15:17 -0700)
committerRobert Griesemer <gri@google.com>
Mon, 24 Oct 2022 16:41:29 +0000 (16:41 +0000)
commit5a3900b23c2bbbf802fa2db9dfea916a6befa517
treeaba12ddfe5c260eac6578a6d5e402d6cbf6a1dfb
parent65f863529ce2d66a63d8be0f62b128feb736a575
go/types, types2: implement alternative comparable semantics

This is an experiment to see the impact of a potential spec change:
As an exception to the rule that constraint satisfaction is the same
as interface implementation, if the flag Config.AltComparableSemantics
is set, an ordinary (non-type parameter) interface satisfies the
comparable constraint. (In go/types, the flag is not exported to
avoid changing the API.)

Disabled by default. Test files can set the flag by adding

// -altComparableSemantics

as the first line in the file.

For #52509.

Change-Id: Ib491b086feb5563920eaddefcebdacb2c5b72d61
Reviewed-on: https://go-review.googlesource.com/c/go/+/444635
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/types2/api.go
src/cmd/compile/internal/types2/check_test.go
src/cmd/compile/internal/types2/instantiate.go
src/cmd/compile/internal/types2/lookup.go
src/cmd/compile/internal/types2/operand.go
src/go/types/api.go
src/go/types/check_test.go
src/go/types/instantiate.go
src/go/types/lookup.go
src/go/types/operand.go
src/internal/types/testdata/spec/comparable.go [new file with mode: 0644]