]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix naming of types inside instantiations
authorDan Scales <danscales@google.com>
Sun, 22 Aug 2021 15:58:24 +0000 (08:58 -0700)
committerDan Scales <danscales@google.com>
Tue, 24 Aug 2021 18:30:13 +0000 (18:30 +0000)
commit5b64381155a779d5392f015e08111906c6e35738
tree9085a1a8fcdeaf7f1f144ba1521258abc8f24620
parent4a9f0cec2918c855a23d5581c0b1da95eb11dd17
cmd/compile: fix naming of types inside instantiations

Issues 47713 and 47877 were both due to problems with the names used for
instantiated functions/methods, which must be in sync with the names
used by types2.

 - Switched to using NameString() for writing out type arguments in
   instantiation names. This ensures that we are always adding the
   package to type names even for the local package. Previously, we were
   explicitly adding the package name for local packages, but that
   doesn't handle the case when the local type is embedded inside a
   pointer or slice type. By switching to NameString(), we fix #47713.

 - types1 and types2 write out 'interface {' differently (vs.
   'interface{') and we were already handling that. But we needed to add
   similar code to handle 'struct {' vs 'struct{'. This fixes issue
   #47877.

While fixing these bugs, I also moved some duplicated code (which
include some of the changes above) into a common function addTargs(). I
also moved InstType() name to subr.go, and renamed: MakeInstName ->
MakeFuncInstSym and MakeDictName -> MakeDictSym.

Also removed a couple of ".inst..inst." prefix checks which are
irrelvant now, since we don't add ".inst." anymore to function
instantiations.

Fixes #47713
Fixes #47877
Fixes #47922

Change-Id: I19e9a073451f3ababd8ec31b6608cd79ba8cba36
Reviewed-on: https://go-review.googlesource.com/c/go/+/344613
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/noder/stencil.go
src/cmd/compile/internal/reflectdata/reflect.go
src/cmd/compile/internal/typecheck/iimport.go
src/cmd/compile/internal/typecheck/subr.go
test/typeparam/issue47713.go [new file with mode: 0644]
test/typeparam/issue47713.out [new file with mode: 0644]
test/typeparam/issue47877.go [new file with mode: 0644]