aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Scales <danscales@google.com>2021-08-24 17:35:51 -0700
committerDan Scales <danscales@google.com>2021-08-26 20:18:58 +0000
commitc9e05fdcf7fd49e9b27f8bcb16347d17d04bc4e7 (patch)
tree5198833f9666a66c14d86aedbbc05629feb25ed2 /test
parenteb6a07fcf99050c447097a8ff6358c484c0f8715 (diff)
downloadgo-c9e05fdcf7fd49e9b27f8bcb16347d17d04bc4e7.tar.gz
go-c9e05fdcf7fd49e9b27f8bcb16347d17d04bc4e7.zip
cmd/compile: fix reference to generic type needed by crawler
This problem happens when you create a new local type that uses an imported generic type (maybe just by instantiating it), and then that local type needed to be included as part of an export. In that case, the imported generic type is does not have a declaration in the local package, so it is not necessarily created in types1, so the crawler/export doesn't work. To fix this issue, we just need to add a call to g.obj() for the base generic type, to make sure that it will exist if needed later in the compilation or for the crawler during export. Fixes #47514 Change-Id: Ie756578f07ad0007de8a88ae909cf7534a22936e Reviewed-on: https://go-review.googlesource.com/c/go/+/345411 Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com>
Diffstat (limited to 'test')
-rw-r--r--test/typeparam/issue47514c.dir/a.go5
-rw-r--r--test/typeparam/issue47514c.dir/main.go10
-rw-r--r--test/typeparam/issue47514c.go7
3 files changed, 22 insertions, 0 deletions
diff --git a/test/typeparam/issue47514c.dir/a.go b/test/typeparam/issue47514c.dir/a.go
new file mode 100644
index 0000000000..782b1d2a4f
--- /dev/null
+++ b/test/typeparam/issue47514c.dir/a.go
@@ -0,0 +1,5 @@
+package a
+
+type Doer[T any] interface {
+ Do() T
+}
diff --git a/test/typeparam/issue47514c.dir/main.go b/test/typeparam/issue47514c.dir/main.go
new file mode 100644
index 0000000000..bc1166f761
--- /dev/null
+++ b/test/typeparam/issue47514c.dir/main.go
@@ -0,0 +1,10 @@
+package main
+
+import "a"
+
+func Do[T any](doer a.Doer[T]) {
+ doer.Do()
+}
+
+func main() {
+}
diff --git a/test/typeparam/issue47514c.go b/test/typeparam/issue47514c.go
new file mode 100644
index 0000000000..76930e5e4f
--- /dev/null
+++ b/test/typeparam/issue47514c.go
@@ -0,0 +1,7 @@
+// rundir -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 ignored