diff options
author | Robert Griesemer <gri@golang.org> | 2021-07-29 11:14:54 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2021-08-02 16:16:21 +0000 |
commit | 283991bd7fb5f0004a8d6c27a8b8038e4d448719 (patch) | |
tree | 914434319a44b9fdd5cb6644dcdf1a30e734453c | |
parent | aa3d54da07bea208cd7c5860875b2d3fbbfeb825 (diff) | |
download | go-283991bd7fb5f0004a8d6c27a8b8038e4d448719.tar.gz go-283991bd7fb5f0004a8d6c27a8b8038e4d448719.zip |
[dev.typeparams] cmd/compile/internal/types2: print constraint info for type param operands
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>
-rw-r--r-- | src/cmd/compile/internal/types2/operand.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/cmd/compile/internal/types2/operand.go b/src/cmd/compile/internal/types2/operand.go index 01c720d1f7..34d35b2594 100644 --- a/src/cmd/compile/internal/types2/operand.go +++ b/src/cmd/compile/internal/types2/operand.go @@ -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") } |