aboutsummaryrefslogtreecommitdiff
path: root/test/typeparam
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2021-11-12 12:38:29 -0800
committerKeith Randall <khr@golang.org>2021-11-14 17:38:42 +0000
commit5337e53dfa3f5fde73b8f505ec3a91c628e8f648 (patch)
treeffe474b92238145243ca2b280a483300f53312d5 /test/typeparam
parentdfa62c79de4f6f6ee2eb8cde340c21afc739c38d (diff)
downloadgo-5337e53dfa3f5fde73b8f505ec3a91c628e8f648.tar.xz
cmd/compile: ensure we replace package placeholder in type names
We want package names exposed by reflect to be things like main.F[main.foo], not main.F["".foo]. Fixes #49547 Change-Id: I182411a75d56ce1f64fde847e5b9ee74ce44e00b Reviewed-on: https://go-review.googlesource.com/c/go/+/363656 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>
Diffstat (limited to 'test/typeparam')
-rw-r--r--test/typeparam/issue49547.go22
-rw-r--r--test/typeparam/nested.out6
2 files changed, 25 insertions, 3 deletions
diff --git a/test/typeparam/issue49547.go b/test/typeparam/issue49547.go
new file mode 100644
index 0000000000..99c124d7ab
--- /dev/null
+++ b/test/typeparam/issue49547.go
@@ -0,0 +1,22 @@
+// run -gcflags=-G=3
+
+// Copyright 2021 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.
+
+package main
+
+import "fmt"
+
+type foo int
+
+func main() {
+ want := "main.F[main.foo]"
+ got := fmt.Sprintf("%T", F[foo]{})
+ if got != want {
+ fmt.Printf("want: %s, got: %s\n", want, got)
+ }
+}
+
+type F[T any] struct {
+}
diff --git a/test/typeparam/nested.out b/test/typeparam/nested.out
index 9110518248..37cb762e32 100644
--- a/test/typeparam/nested.out
+++ b/test/typeparam/nested.out
@@ -1,4 +1,4 @@
0,3: main.T·2[int;int]
-4,7: main.T·2[int;"".U·3[int;int]]
-22,23: main.T·2["".Int;"".Int]
-26,27: main.T·2["".Int;"".U·3["".Int;"".Int]]
+4,7: main.T·2[int;main.U·3[int;int]]
+22,23: main.T·2[main.Int;main.Int]
+26,27: main.T·2[main.Int;main.U·3[main.Int;main.Int]]