]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] go/types: print constraint info for type param operands
authorRob Findley <rfindley@google.com>
Wed, 4 Aug 2021 01:39:53 +0000 (21:39 -0400)
committerRobert Findley <rfindley@google.com>
Wed, 4 Aug 2021 11:07:26 +0000 (11:07 +0000)
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>
src/go/types/operand.go

index c605cf781cee4a07ef90daebddf884d1cd01f09c..aea8bf5e7ad11b9a378503d5bb42f14cd47712a2 100644 (file)
@@ -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")
                }