[dev.typeparams] cmd/compile/internal/types: format union types

Previously it was just printing <S>. Now it prints things like int32|~int64.

Change-Id: I960b011ce8ed360020a49ae7809d85d1d1fdbfb2
Reviewed-on: https://go-review.googlesource.com/c/go/+/336692
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
This commit is contained in:
Keith Randall 2021-07-22 15:30:01 -07:00
parent 244267e8c4
commit 4cdc65d32a

View file

@ -590,6 +590,18 @@ func tconv2(b *bytes.Buffer, t *Type, verb rune, mode fmtMode, visited map[*Type
b.WriteString(fmt.Sprintf("%p", t))
}
case TUNION:
for i := 0; i < t.NumTerms(); i++ {
if i > 0 {
b.WriteString("|")
}
elem, tilde := t.Term(i)
if tilde {
b.WriteString("~")
}
tconv2(b, elem, 0, mode, visited)
}
case Txxx:
b.WriteString("Txxx")