go/internal/gcimporter: key tparams by Package instead of pkgname
This is a port of CL 394219 to x/tools. A test is added to reproduce the
failure mode using the x/tools gcimporter.
Updates #51836
Change-Id: I521d4947b084fe9dae08de96450568e0dd5399b0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/400815
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/go/internal/gcimporter/iimport.go b/go/internal/gcimporter/iimport.go
index 1d5650a..28b91b8 100644
--- a/go/internal/gcimporter/iimport.go
+++ b/go/internal/gcimporter/iimport.go
@@ -53,7 +53,7 @@
)
type ident struct {
- pkg string
+ pkg *types.Package
name string
}
@@ -463,7 +463,7 @@
// To handle recursive references to the typeparam within its
// bound, save the partial type in tparamIndex before reading the bounds.
- id := ident{r.currPkg.Name(), name}
+ id := ident{r.currPkg, name}
r.p.tparamIndex[id] = t
var implicit bool
if r.p.version >= iexportVersionGo1_18 {
@@ -779,7 +779,7 @@
errorf("unexpected type param type")
}
pkg, name := r.qualifiedIdent()
- id := ident{pkg.Name(), name}
+ id := ident{pkg, name}
if t, ok := r.p.tparamIndex[id]; ok {
// We're already in the process of importing this typeparam.
return t