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()
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)
// 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")
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)
}
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 {