diff --git a/src/cmd/compile/internal/gc/closure.go b/src/cmd/compile/internal/gc/closure.go index 07064415f4..f6b492a16f 100644 --- a/src/cmd/compile/internal/gc/closure.go +++ b/src/cmd/compile/internal/gc/closure.go @@ -434,8 +434,15 @@ func makepartialcall(fn *Node, t0 *types.Type, meth *types.Sym) *Node { sym.SetUniq(true) savecurfn := Curfn + saveLineNo := lineno Curfn = nil + // Set line number equal to the line number where the method is declared. + var m *types.Field + if lookdot0(meth, rcvrtype, &m, false) == 1 { + lineno = m.Pos + } + tfn := nod(OTFUNC, nil, nil) tfn.List.Set(structargs(t0.Params(), true)) tfn.Rlist.Set(structargs(t0.Results(), false)) @@ -482,6 +489,7 @@ func makepartialcall(fn *Node, t0 *types.Type, meth *types.Sym) *Node { sym.Def = asTypesNode(xfunc) xtop = append(xtop, xfunc) Curfn = savecurfn + lineno = saveLineNo return xfunc }