aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Findley <rfindley@google.com>2021-08-03 21:39:53 -0400
committerRobert Findley <rfindley@google.com>2021-08-04 11:07:26 +0000
commitb01e775e9c05dd2e5fa19ea06ac09f9a12ae660e (patch)
tree04b51a23ea7b0933a52abcfaca7f1d9bd735f142
parent3efc8f9a8dc93ccacb8b139cafc44ee0709d8fdd (diff)
downloadgo-b01e775e9c05dd2e5fa19ea06ac09f9a12ae660e.tar.gz
go-b01e775e9c05dd2e5fa19ea06ac09f9a12ae660e.zip
[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>
-rw-r--r--src/go/types/operand.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/go/types/operand.go b/src/go/types/operand.go
index c605cf781c..aea8bf5e7a 100644
--- a/src/go/types/operand.go
+++ b/src/go/types/operand.go
@@ -159,16 +159,20 @@ func operandString(x *operand, qf Qualifier) string {
if hasType {
if x.typ != Typ[Invalid] {
var intro string
- switch {
- case isGeneric(x.typ):
- intro = " of generic type "
- case asTypeParam(x.typ) != nil:
- intro = " of type parameter type "
- default:
+ var tpar *TypeParam
+ if isGeneric(x.typ) {
+ intro = " of parameterized type "
+ } else if tpar = asTypeParam(x.typ); tpar != nil {
+ intro = " of type parameter "
+ } else {
intro = " of type "
}
buf.WriteString(intro)
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 {
buf.WriteString(" with invalid type")
}