"*cmd/compile/internal/types.Sym %v": "",
"*cmd/compile/internal/types.Type %#L": "",
"*cmd/compile/internal/types.Type %#v": "",
- "*cmd/compile/internal/types.Type %+v": "",
"*cmd/compile/internal/types.Type %-S": "",
"*cmd/compile/internal/types.Type %0S": "",
"*cmd/compile/internal/types.Type %L": "",
fn.Right = newname(sym)
fn.Op = OCALLPART
fn.Type = xfunc.Type
+ fn.SetOpt(nil) // clear types.Field from ODOTMETH
}
// makepartialcall returns a DCLFUNC node representing the wrapper function (*-fm) needed
if t == nil {
Fatalf("no function type for [%p] %+v\n", n.Left, n.Left)
}
- if t.Nname() == nil {
- Fatalf("no function definition for [%p] %+v\n", t, t)
- }
if isRuntimePkg(n.Left.Sym.Pkg) {
fn := n.Left.Sym.Name
if fn == "heapBits.nextArena" {
break
}
}
- if inlfn := asNode(t.FuncType().Nname).Func; inlfn.Inl != nil {
+ if inlfn := n.Left.MethodName().Func; inlfn.Inl != nil {
v.budget -= inlfn.Inl.Cost
break
}
Fatalf("no function type for [%p] %+v\n", n.Left, n.Left)
}
- if n.Left.Type.Nname() == nil {
- Fatalf("no function definition for [%p] %+v\n", n.Left.Type, n.Left.Type)
- }
-
- n = mkinlcall(n, asNode(n.Left.Type.FuncType().Nname), maxCost, inlMap)
+ n = mkinlcall(n, n.Left.MethodName(), maxCost, inlMap)
}
lineno = lno
// SetOpt sets the optimizer data for the node, which must not have been used with SetVal.
// SetOpt(nil) is ignored for Vals to simplify call sites that are clearing Opts.
func (n *Node) SetOpt(x interface{}) {
- if x == nil && n.HasVal() {
+ if x == nil {
+ if n.HasOpt() {
+ n.SetHasOpt(false)
+ n.E = nil
+ }
return
}
if n.HasVal() {
n.Type = methodfunc(m.Type, n.Left.Type)
n.Xoffset = 0
n.SetClass(PFUNC)
+ n.SetOpt(m)
// methodSym already marked n.Sym as a function.
// Issue 25065. Make sure that we emit the symbol for a local method.
n.Xoffset = f2.Offset
n.Type = f2.Type
n.Op = ODOTMETH
+ n.SetOpt(f2)
return f2
}
return fnpkg(fn)
}
+
+// MethodName returns the ONAME representing the method
+// referenced by expression n, which must be a method selector,
+// method expression, or method value.
+func (n *Node) MethodName() *Node {
+ return asNode(n.MethodFunc().Type.Nname())
+}
+
+// MethodFunc is like MethodName, but returns the types.Field instead.
+func (n *Node) MethodFunc() *types.Field {
+ switch {
+ case n.Op == ODOTMETH || n.isMethodExpression():
+ return n.Opt().(*types.Field)
+ case n.Op == OCALLPART:
+ return callpartMethod(n)
+ }
+ Fatalf("unexpected node: %v (%v)", n, n.Op)
+ panic("unreachable")
+}