]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/api: include type arguments in API
authorMatthew Dempsky <mdempsky@google.com>
Fri, 26 Jan 2024 04:29:32 +0000 (20:29 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 26 Jan 2024 19:39:32 +0000 (19:39 +0000)
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 <rfindley@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

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

index 7985055b5c0de2ecf8634f51fa48db9ae21cb8eb..0a3d44ddd0aaaab76c4e4d3b8b0ed84e91d287b2 100644 (file)
@@ -851,6 +851,16 @@ func (w *Walker) writeType(buf *bytes.Buffer, typ types.Type) {
                        buf.WriteByte('.')
                }
                buf.WriteString(typ.Obj().Name())
+               if targs := typ.TypeArgs(); targs.Len() > 0 {
+                       buf.WriteByte('[')
+                       for i := 0; i < targs.Len(); i++ {
+                               if i > 0 {
+                                       buf.WriteString(", ")
+                               }
+                               w.writeType(buf, targs.At(i))
+                       }
+                       buf.WriteByte(']')
+               }
 
        case *types.TypeParam:
                // Type parameter names may change, so use a placeholder instead.
index eec0598dcd1da1ca822b83897026f7a3e15f992d..1ceae17386339b1eb837729f5b5d5665a83cbf1f 100644 (file)
@@ -1,4 +1,4 @@
-pkg p4, func NewPair[$0 interface{ M }, $1 interface{ ~int }]($0, $1) Pair
+pkg p4, func NewPair[$0 interface{ M }, $1 interface{ ~int }]($0, $1) Pair[$0, $1]
 pkg p4, method (Pair[$0, $1]) Second() $1
 pkg p4, method (Pair[$0, $1]) First() $0
 pkg p4, type Pair[$0 interface{ M }, $1 interface{ ~int }] struct