mirror of
https://github.com/golang/go
synced 2024-11-14 07:20:22 -07:00
[dev.typeparams] go/types: print constraint info for type param operands
This is a clean port of CL 338309 to go/types. Change-Id: Ie2c9e2ea51d6321af8bf149e43cd71b7ac282d13 Reviewed-on: https://go-review.googlesource.com/c/go/+/339676 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
3efc8f9a8d
commit
b01e775e9c
@ -159,16 +159,20 @@ func operandString(x *operand, qf Qualifier) string {
|
|||||||
if hasType {
|
if hasType {
|
||||||
if x.typ != Typ[Invalid] {
|
if x.typ != Typ[Invalid] {
|
||||||
var intro string
|
var intro string
|
||||||
switch {
|
var tpar *TypeParam
|
||||||
case isGeneric(x.typ):
|
if isGeneric(x.typ) {
|
||||||
intro = " of generic type "
|
intro = " of parameterized type "
|
||||||
case asTypeParam(x.typ) != nil:
|
} else if tpar = asTypeParam(x.typ); tpar != nil {
|
||||||
intro = " of type parameter type "
|
intro = " of type parameter "
|
||||||
default:
|
} else {
|
||||||
intro = " of type "
|
intro = " of type "
|
||||||
}
|
}
|
||||||
buf.WriteString(intro)
|
buf.WriteString(intro)
|
||||||
WriteType(&buf, x.typ, qf)
|
WriteType(&buf, x.typ, qf)
|
||||||
|
if tpar != nil {
|
||||||
|
buf.WriteString(" constrained by ")
|
||||||
|
WriteType(&buf, tpar.bound, qf) // do not compute interface type sets here
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
buf.WriteString(" with invalid type")
|
buf.WriteString(" with invalid type")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user