mirror of https://github.com/golang/go.git
cmd/compile: eliminate addmethod tpkg parameter
It's only needed for a check that can be pushed up into bimport.go, where it makes more sense anyway. Change-Id: I6ef381ff4f29627b0f390ce27fef08902932bea6 Reviewed-on: https://go-review.googlesource.com/28177 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
4710e16d34
commit
d57a4a656a
|
|
@ -467,6 +467,11 @@ func (p *importer) typ() *Type {
|
|||
p.pos()
|
||||
sym := p.fieldSym()
|
||||
|
||||
// during import unexported method names should be in the type's package
|
||||
if !exportname(sym.Name) && sym.Pkg != tsym.Pkg {
|
||||
Fatalf("imported method name %v in wrong package %s\n", sconv(sym, FmtSign), tsym.Pkg.Name)
|
||||
}
|
||||
|
||||
recv := p.paramList() // TODO(gri) do we need a full param list for the receiver?
|
||||
params := p.paramList()
|
||||
result := p.paramList()
|
||||
|
|
@ -475,7 +480,7 @@ func (p *importer) typ() *Type {
|
|||
n := methodname(newname(sym), recv[0].Right)
|
||||
n.Type = functype(recv[0], params, result)
|
||||
checkwidth(n.Type)
|
||||
addmethod(sym, n.Type, tsym.Pkg, false, nointerface)
|
||||
addmethod(sym, n.Type, false, nointerface)
|
||||
p.funcList = append(p.funcList, n)
|
||||
importlist = append(importlist, n)
|
||||
|
||||
|
|
|
|||
|
|
@ -1153,8 +1153,7 @@ func methodname(n *Node, t *Node) *Node {
|
|||
// Add a method, declared as a function.
|
||||
// - msym is the method symbol
|
||||
// - t is function type (with receiver)
|
||||
// - tpkg is the package of the type declaring the method during import, or nil (ignored) --- for verification only
|
||||
func addmethod(msym *Sym, t *Type, tpkg *Pkg, local, nointerface bool) {
|
||||
func addmethod(msym *Sym, t *Type, local, nointerface bool) {
|
||||
// get field sym
|
||||
if msym == nil {
|
||||
Fatalf("no method symbol")
|
||||
|
|
@ -1232,11 +1231,6 @@ func addmethod(msym *Sym, t *Type, tpkg *Pkg, local, nointerface bool) {
|
|||
f := structfield(n)
|
||||
f.Nointerface = nointerface
|
||||
|
||||
// during import unexported method names should be in the type's package
|
||||
if tpkg != nil && f.Sym != nil && !exportname(f.Sym.Name) && f.Sym.Pkg != tpkg {
|
||||
Fatalf("imported method name %v in wrong package %s\n", sconv(f.Sym, FmtSign), tpkg.Name)
|
||||
}
|
||||
|
||||
mt.Methods().Append(f)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3388,7 +3388,7 @@ func typecheckfunc(n *Node) {
|
|||
t.SetNname(n.Func.Nname)
|
||||
rcvr := t.Recv()
|
||||
if rcvr != nil && n.Func.Shortname != nil {
|
||||
addmethod(n.Func.Shortname.Sym, t, nil, true, n.Func.Pragma&Nointerface != 0)
|
||||
addmethod(n.Func.Shortname.Sym, t, true, n.Func.Pragma&Nointerface != 0)
|
||||
}
|
||||
|
||||
for _, ln := range n.Func.Dcl {
|
||||
|
|
|
|||
Loading…
Reference in New Issue