diff --git a/src/cmd/compile/internal/types2/typestring.go b/src/cmd/compile/internal/types2/typestring.go index 4d778df43f5..47b2c259e5a 100644 --- a/src/cmd/compile/internal/types2/typestring.go +++ b/src/cmd/compile/internal/types2/typestring.go @@ -1,4 +1,3 @@ -// UNREVIEWED // Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. @@ -314,33 +313,16 @@ func writeTypeList(buf *bytes.Buffer, list []Type, qf Qualifier, visited []Type) } func writeTParamList(buf *bytes.Buffer, list []*TypeName, qf Qualifier, visited []Type) { - // bound returns the type bound for tname. The result is never nil. - bound := func(tname *TypeName) Type { - // be careful to avoid crashes in case of inconsistencies - if t, _ := tname.typ.(*TypeParam); t != nil && t.bound != nil { - return t.bound - } - return &emptyInterface - } - - // If a single type bound is not the empty interface, we have to write them all. - var writeBounds bool - for _, p := range list { - // bound(p) should be an interface but be careful (it may be invalid) - b := asInterface(bound(p)) - if b != nil && !b.Empty() { - writeBounds = true - break - } - } - writeBounds = true // always write the bounds for new type parameter list syntax - buf.WriteString("[") var prev Type for i, p := range list { - b := bound(p) + // TODO(gri) support 'any' sugar here. + var b Type = &emptyInterface + if t, _ := p.typ.(*TypeParam); t != nil && t.bound != nil { + b = t.bound + } if i > 0 { - if writeBounds && b != prev { + if b != prev { // type bound changed - write previous one before advancing buf.WriteByte(' ') writeType(buf, prev, qf, visited) @@ -355,7 +337,7 @@ func writeTParamList(buf *bytes.Buffer, list []*TypeName, qf Qualifier, visited buf.WriteString(p.name) } } - if writeBounds && prev != nil { + if prev != nil { buf.WriteByte(' ') writeType(buf, prev, qf, visited) }