aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/typecheck/dcl.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2020-12-25 00:34:32 -0800
committerMatthew Dempsky <mdempsky@google.com>2020-12-25 11:15:41 +0000
commite4f293d85306cb89da3c134ce432e330e289447e (patch)
treed1279fe95eee2592def7007c604356efd9e7bbd7 /src/cmd/compile/internal/typecheck/dcl.go
parent1d9a1f67d537309f80740b16ef619500fb55db16 (diff)
downloadgo-e4f293d85306cb89da3c134ce432e330e289447e.tar.gz
go-e4f293d85306cb89da3c134ce432e330e289447e.zip
[dev.regabi] cmd/compile: fix OCALLMETH desugaring
During walkCall, there's a half-hearted attempt at rewriting OCALLMETH expressions into regular function calls by moving the receiver argument into n.Args with the rest of the arguments. But the way it does this leaves the AST in an inconsistent state (an ODOTMETH node with no X expression), and leaves a lot of duplicate work for the rest of the backend to deal with. By simply rewriting OCALLMETH expressions into proper OCALLFUNC expressions, we eliminate a ton of unnecessary code duplication during SSA construction and avoid creation of invalid method-typed variables. Passes toolstash -cmp. Change-Id: I4d5c5f90a79f8994059b2d0ae472182e08096c0a Reviewed-on: https://go-review.googlesource.com/c/go/+/280294 Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/dcl.go')
-rw-r--r--src/cmd/compile/internal/typecheck/dcl.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/typecheck/dcl.go b/src/cmd/compile/internal/typecheck/dcl.go
index db18c17e13..0da0956c3a 100644
--- a/src/cmd/compile/internal/typecheck/dcl.go
+++ b/src/cmd/compile/internal/typecheck/dcl.go
@@ -556,6 +556,9 @@ func TempAt(pos src.XPos, curfn *ir.Func, t *types.Type) *ir.Name {
if t == nil {
base.Fatalf("tempAt called with nil type")
}
+ if t.Kind() == types.TFUNC && t.Recv() != nil {
+ base.Fatalf("misuse of method type: %v", t)
+ }
s := &types.Sym{
Name: autotmpname(len(curfn.Dcl)),