]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] cmd/compile/internal/types: format union types
authorKeith Randall <khr@golang.org>
Thu, 22 Jul 2021 22:30:01 +0000 (15:30 -0700)
committerKeith Randall <khr@golang.org>
Fri, 23 Jul 2021 03:55:44 +0000 (03:55 +0000)
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>
src/cmd/compile/internal/types/fmt.go

index a52dd060a015e4c5d7322adb6fa1a60e8daa9c9a..0824f6d0936161fdf126760284c613a1eb5f09fc 100644 (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")