]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] cmd/compile/internal/types2: print constraint info for type param...
authorRobert Griesemer <gri@golang.org>
Thu, 29 Jul 2021 18:14:54 +0000 (11:14 -0700)
committerRobert Griesemer <gri@golang.org>
Mon, 2 Aug 2021 16:16:21 +0000 (16:16 +0000)
Change-Id: Ic7a249fc150b526835db744431bef500c20fbd26
Reviewed-on: https://go-review.googlesource.com/c/go/+/338309
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/operand.go

index 01c720d1f787598aa7f4179edfb47d6a62bf8838..34d35b25947b063fcd744bc71a0f202ad4125d26 100644 (file)
@@ -176,16 +176,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")
                }