]> Cypherpunks.ru repositories - gostls13.git/commit
go/types, types2: add "dynamic" flag to comparable predicate
authorRobert Griesemer <gri@golang.org>
Sun, 20 Feb 2022 20:58:21 +0000 (12:58 -0800)
committerRobert Griesemer <gri@golang.org>
Wed, 23 Feb 2022 20:51:26 +0000 (20:51 +0000)
commit163da6feb525a98dab5c1f01d81b2c705ead51ea
tree0ca6c9eff2957fb140b428be5d5c9f768d4401f0
parente534907f65f5a3eda47a069ea0aab33306c1d616
go/types, types2: add "dynamic" flag to comparable predicate

A type implements a comparable interface only if the type
is statically known to be comparable. Specifically, a type
cannot contain (component) interfaces that are not statically
known to be comparable.

This CL adds a flag "dynamic" to the comparable predicate to
control whether interfaces are always (dynamically) comparable.
Set the flag to true when testing for (traditional) Go comparability;
set the flag to false when testing whether a type implements the
comparable interface.

Fixes #51257.

Change-Id: If22bc047ee59337deb2e7844b8f488d67e5c5530
Reviewed-on: https://go-review.googlesource.com/c/go/+/387055
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/expr.go
src/cmd/compile/internal/types2/instantiate.go
src/cmd/compile/internal/types2/predicates.go
src/cmd/compile/internal/types2/testdata/fixedbugs/issue51257.go2 [new file with mode: 0644]
src/cmd/compile/internal/types2/typeset.go
src/go/types/expr.go
src/go/types/instantiate.go
src/go/types/predicates.go
src/go/types/testdata/fixedbugs/issue51257.go2 [new file with mode: 0644]
src/go/types/typeset.go