1
0
mirror of https://github.com/golang/go synced 2024-11-18 07:04:52 -07:00
go/test/fixedbugs/issue43479.dir/b.go

39 lines
611 B
Go
Raw Normal View History

[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>
2021-01-03 15:37:06 -07:00
// Copyright 2020 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 b
import "./a"
var Here = a.New()
var Dir = Here.Dir
type T = struct {
a.Here
a.I
}
var X T
// Test exporting the type of method values for anonymous structs with
// promoted methods.
var A = a.A
var B = a.B
var C = a.C
var D = a.D
var E = a.E
var F = a.F
var G = (*a.T).Dir
var H = a.T.Dir
var I = a.X.Dir
var J = (*a.T).M
var K = a.T.M
var L = a.X.M
var M = (*T).Dir
var N = T.Dir
var O = X.Dir
var P = (*T).M
var Q = T.M
var R = X.M