Skip to content

Commit b6d1eb7

Browse files
committed
cmd/api: include type arguments in API
T[A] and T[B] are different types, but we were writing them both as just "T". Reported by Russ. Change-Id: I27db35946b6d3a1fad6c56c785fa6d850ad71d00 Reviewed-on: https://go-review.googlesource.com/c/go/+/558716 Reviewed-by: Robert Findley <[email protected]> Auto-Submit: Matthew Dempsky <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent a428387 commit b6d1eb7

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/cmd/api/main_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,16 @@ func (w *Walker) writeType(buf *bytes.Buffer, typ types.Type) {
851851
buf.WriteByte('.')
852852
}
853853
buf.WriteString(typ.Obj().Name())
854+
if targs := typ.TypeArgs(); targs.Len() > 0 {
855+
buf.WriteByte('[')
856+
for i := 0; i < targs.Len(); i++ {
857+
if i > 0 {
858+
buf.WriteString(", ")
859+
}
860+
w.writeType(buf, targs.At(i))
861+
}
862+
buf.WriteByte(']')
863+
}
854864

855865
case *types.TypeParam:
856866
// Type parameter names may change, so use a placeholder instead.

src/cmd/api/testdata/src/pkg/p4/golden.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pkg p4, func NewPair[$0 interface{ M }, $1 interface{ ~int }]($0, $1) Pair
1+
pkg p4, func NewPair[$0 interface{ M }, $1 interface{ ~int }]($0, $1) Pair[$0, $1]
22
pkg p4, method (Pair[$0, $1]) Second() $1
33
pkg p4, method (Pair[$0, $1]) First() $0
44
pkg p4, type Pair[$0 interface{ M }, $1 interface{ ~int }] struct

0 commit comments

Comments
 (0)