diff options
author | Matthew Dempsky <mdempsky@google.com> | 2020-12-28 16:14:11 -0800 |
---|---|---|
committer | Matthew Dempsky <mdempsky@google.com> | 2020-12-29 02:35:04 +0000 |
commit | 4629f6a51da5afabbebe9616f65fbfe0675d6039 (patch) | |
tree | 8e81fbaa7ef4a2efc7cbc750df95c0eb817a4bee /src/cmd/compile/internal/typecheck/typecheck.go | |
parent | e563715b3085f44a76564485214e33e3c3b2b7b0 (diff) | |
download | go-4629f6a51da5afabbebe9616f65fbfe0675d6039.tar.gz go-4629f6a51da5afabbebe9616f65fbfe0675d6039.zip |
[dev.regabi] cmd/compile: merge {Selector,CallPart,Method}Expr
These three expression nodes all represent the same syntax, and so
they're represented the same within types2. And also they're not
handled that meaningfully differently throughout the rest of the
compiler to merit unique representations.
Method expressions are somewhat unique today that they're very
frequently turned into plain function names. But eventually that can
be handled by a post-typecheck desugaring phase that reduces the
number of redundant AST forms.
Passes toolstash -cmp.
Change-Id: I20df91bbd0d885c1f18ec67feb61ae1558670719
Reviewed-on: https://go-review.googlesource.com/c/go/+/280636
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/typecheck.go')
-rw-r--r-- | src/cmd/compile/internal/typecheck/typecheck.go | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/cmd/compile/internal/typecheck/typecheck.go b/src/cmd/compile/internal/typecheck/typecheck.go index e23c249ff2..ff9178b597 100644 --- a/src/cmd/compile/internal/typecheck/typecheck.go +++ b/src/cmd/compile/internal/typecheck/typecheck.go @@ -1176,19 +1176,16 @@ func typecheckMethodExpr(n *ir.SelectorExpr) (res ir.Node) { return n } - me := ir.NewMethodExpr(n.Pos(), n.X.Type(), m) - me.SetType(NewMethodType(m.Type, n.X.Type())) - f := NewName(ir.MethodSym(t, m.Sym)) - f.Class_ = ir.PFUNC - f.SetType(me.Type()) - me.FuncName_ = f + n.SetOp(ir.OMETHEXPR) + n.Selection = m + n.SetType(NewMethodType(m.Type, n.X.Type())) // Issue 25065. Make sure that we emit the symbol for a local method. if base.Ctxt.Flag_dynlink && !inimport && (t.Sym() == nil || t.Sym().Pkg == types.LocalPkg) { - NeedFuncSym(me.FuncName_.Sym()) + NeedFuncSym(n.FuncName().Sym()) } - return me + return n } func derefall(t *types.Type) *types.Type { @@ -1422,7 +1419,7 @@ notenough: // Method expressions have the form T.M, and the compiler has // rewritten those to ONAME nodes but left T in Left. if call.Op() == ir.OMETHEXPR { - call := call.(*ir.MethodExpr) + call := call.(*ir.SelectorExpr) base.Errorf("not enough arguments in call to method expression %v%s", call, details) } else { base.Errorf("not enough arguments in call to %v%s", call, details) |