Commit d57a4a65 authored by Matthew Dempsky's avatar Matthew Dempsky

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: default avatarRobert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 4710e16d
...@@ -467,6 +467,11 @@ func (p *importer) typ() *Type { ...@@ -467,6 +467,11 @@ func (p *importer) typ() *Type {
p.pos() p.pos()
sym := p.fieldSym() 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? recv := p.paramList() // TODO(gri) do we need a full param list for the receiver?
params := p.paramList() params := p.paramList()
result := p.paramList() result := p.paramList()
...@@ -475,7 +480,7 @@ func (p *importer) typ() *Type { ...@@ -475,7 +480,7 @@ func (p *importer) typ() *Type {
n := methodname(newname(sym), recv[0].Right) n := methodname(newname(sym), recv[0].Right)
n.Type = functype(recv[0], params, result) n.Type = functype(recv[0], params, result)
checkwidth(n.Type) checkwidth(n.Type)
addmethod(sym, n.Type, tsym.Pkg, false, nointerface) addmethod(sym, n.Type, false, nointerface)
p.funcList = append(p.funcList, n) p.funcList = append(p.funcList, n)
importlist = append(importlist, n) importlist = append(importlist, n)
......
...@@ -1153,8 +1153,7 @@ func methodname(n *Node, t *Node) *Node { ...@@ -1153,8 +1153,7 @@ func methodname(n *Node, t *Node) *Node {
// Add a method, declared as a function. // Add a method, declared as a function.
// - msym is the method symbol // - msym is the method symbol
// - t is function type (with receiver) // - 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, local, nointerface bool) {
func addmethod(msym *Sym, t *Type, tpkg *Pkg, local, nointerface bool) {
// get field sym // get field sym
if msym == nil { if msym == nil {
Fatalf("no method symbol") Fatalf("no method symbol")
...@@ -1232,11 +1231,6 @@ func addmethod(msym *Sym, t *Type, tpkg *Pkg, local, nointerface bool) { ...@@ -1232,11 +1231,6 @@ func addmethod(msym *Sym, t *Type, tpkg *Pkg, local, nointerface bool) {
f := structfield(n) f := structfield(n)
f.Nointerface = nointerface 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) mt.Methods().Append(f)
} }
......
...@@ -3388,7 +3388,7 @@ func typecheckfunc(n *Node) { ...@@ -3388,7 +3388,7 @@ func typecheckfunc(n *Node) {
t.SetNname(n.Func.Nname) t.SetNname(n.Func.Nname)
rcvr := t.Recv() rcvr := t.Recv()
if rcvr != nil && n.Func.Shortname != nil { 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 { for _, ln := range n.Func.Dcl {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment