aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRobert Findley <rfindley@google.com>2022-03-21 16:08:38 -0400
committerRobert Findley <rfindley@google.com>2022-03-22 21:38:10 +0000
commitfd1b5904ae7cc76eefd94d315f92265da5b81b14 (patch)
treea37f42d355dfff868fa8ac71b05a626c866441f1 /test
parent212bda066996d1ed06e738c8b408bb2b65896064 (diff)
downloadgo-fd1b5904ae7cc76eefd94d315f92265da5b81b14.tar.gz
go-fd1b5904ae7cc76eefd94d315f92265da5b81b14.zip
cmd/compile/internal/importer: key tparams by Package instead of pkgname
The importer type param index used package name type parameter key, causing type parameters to be reused/overwritten if two packages in the import graph had the same combination of (name, declaration name, type parameter name). Fix this by instead using the *Package in the key. Fixes #51836 Change-Id: I881ceaf3cf7c1ab4e0835962350feb552e79b233 Reviewed-on: https://go-review.googlesource.com/c/go/+/394219 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'test')
-rw-r--r--test/typeparam/issue51836.dir/a.go8
-rw-r--r--test/typeparam/issue51836.dir/aa.go13
-rw-r--r--test/typeparam/issue51836.dir/p.go11
-rw-r--r--test/typeparam/issue51836.go7
4 files changed, 39 insertions, 0 deletions
diff --git a/test/typeparam/issue51836.dir/a.go b/test/typeparam/issue51836.dir/a.go
new file mode 100644
index 00000000000..e9223c9aa82
--- /dev/null
+++ b/test/typeparam/issue51836.dir/a.go
@@ -0,0 +1,8 @@
+// Copyright 2022 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 a
+
+type T[K any] struct {
+}
diff --git a/test/typeparam/issue51836.dir/aa.go b/test/typeparam/issue51836.dir/aa.go
new file mode 100644
index 00000000000..d774be282e5
--- /dev/null
+++ b/test/typeparam/issue51836.dir/aa.go
@@ -0,0 +1,13 @@
+// Copyright 2022 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 a
+
+import (
+ "./a"
+)
+
+type T[K any] struct {
+ t a.T[K]
+}
diff --git a/test/typeparam/issue51836.dir/p.go b/test/typeparam/issue51836.dir/p.go
new file mode 100644
index 00000000000..98197ae0fd9
--- /dev/null
+++ b/test/typeparam/issue51836.dir/p.go
@@ -0,0 +1,11 @@
+// Copyright 2022 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 p
+
+import (
+ a "./aa"
+)
+
+var Foo a.T[int]
diff --git a/test/typeparam/issue51836.go b/test/typeparam/issue51836.go
new file mode 100644
index 00000000000..c755e74b9cd
--- /dev/null
+++ b/test/typeparam/issue51836.go
@@ -0,0 +1,7 @@
+// compiledir -s
+
+// Copyright 2022 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 ignored