]> Cypherpunks repositories - gostls13.git/commit
[dev.regabi] cmd/compile: fix re-export of parameters
authorMatthew Dempsky <mdempsky@google.com>
Sun, 3 Jan 2021 22:37:06 +0000 (14:37 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 4 Jan 2021 10:30:08 +0000 (10:30 +0000)
commitd89705e08742c0f4fdf5d2bdbab6f344c6be884f
tree1f9dc4336efac6988c5132bf3b101f046d6aa549
parent290b4154b73b54045a147f463c6988b935d75d49
[dev.regabi] cmd/compile: fix re-export of parameters

When exporting signature types, we include the originating package,
because it's exposed via go/types's API. And as a consistency check,
we ensure that the parameter names came from that same package.

However, we were getting this wrong in the case of exported variables
that were initialized with a method value using an imported method. In
this case, when we created the method value wrapper function's
type (which is reused as the variable's type if none is explicitly
provided in the variable declaration), we were reusing the
original (i.e., imported) parameter names, but the newly created
signature type was associated with the current package instead.

The correct fix here is really to preserve the original signature
type's package (along with position and name for its parameters), but
that's awkward to do at the moment because the DeclFunc API requires
an ir representation of the function signature, whereas we only
provide a way to explicitly set packages via the type constructor
APIs.

As an interim fix, we associate the parameters with the current
package, to be consistent with the signature type's package.

Fixes #43479.

Change-Id: Id45a10f8cf64165c9bc7d9598f0a0ee199a5e752
Reviewed-on: https://go-review.googlesource.com/c/go/+/281292
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
src/cmd/compile/internal/typecheck/dcl.go
src/cmd/compile/internal/typecheck/iexport.go
src/cmd/compile/internal/typecheck/iimport.go
src/cmd/compile/internal/typecheck/subr.go
test/fixedbugs/issue43479.dir/a.go [new file with mode: 0644]
test/fixedbugs/issue43479.dir/b.go [new file with mode: 0644]
test/fixedbugs/issue43479.go [new file with mode: 0644]