For #50791.
Change-Id: Ib12009d2895146e55ec3a51aa8ceafe58dfd82a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/380754
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
}
case *Interface:
- if t == universeAny.Type() && w.ctxt == nil {
- // When not hashing, we can try to improve type strings by writing "any"
- // for a type that is pointer-identical to universeAny. This logic should
- // be deprecated by more robust handling for aliases.
- w.string("any")
- break
+ if w.ctxt == nil {
+ if t == universeAny.Type() {
+ // When not hashing, we can try to improve type strings by writing "any"
+ // for a type that is pointer-identical to universeAny. This logic should
+ // be deprecated by more robust handling for aliases.
+ w.string("any")
+ break
+ }
+ if t == universeComparable.Type().(*Named).underlying {
+ w.string("interface{comparable}")
+ break
+ }
}
if t.implicit {
if len(t.methods) == 0 && len(t.embeddeds) == 1 {
dup(`interface{String() string; m(int) float32}`),
dup("interface{int|float32|complex128}"),
dup("interface{int|~float32|~complex128}"),
+ dup("any"),
+ dup("interface{comparable}"),
+ {"comparable", "interface{comparable}"},
+ {"error", "interface{Error() string}"},
// maps
dup("map[string]int"),
}
case *Interface:
- if t == universeAny.Type() && w.ctxt == nil {
- // When not hashing, we can try to improve type strings by writing "any"
- // for a type that is pointer-identical to universeAny. This logic should
- // be deprecated by more robust handling for aliases.
- w.string("any")
- break
+ if w.ctxt == nil {
+ if t == universeAny.Type() {
+ // When not hashing, we can try to improve type strings by writing "any"
+ // for a type that is pointer-identical to universeAny. This logic should
+ // be deprecated by more robust handling for aliases.
+ w.string("any")
+ break
+ }
+ if t == universeComparable.Type().(*Named).underlying {
+ w.string("interface{comparable}")
+ break
+ }
}
if t.implicit {
if len(t.methods) == 0 && len(t.embeddeds) == 1 {
dup(`interface{String() string; m(int) float32}`),
dup("interface{int|float32|complex128}"),
dup("interface{int|~float32|~complex128}"),
+ dup("any"),
+ dup("interface{comparable}"),
+ // TODO(gri) adjust test for EvalCompositeTest
+ // {"comparable", "interface{comparable}"},
+ // {"error", "interface{Error() string}"},
// maps
dup("map[string]int"),