aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Scales <danscales@google.com>2020-10-19 13:09:55 -0700
committerDan Scales <danscales@google.com>2020-10-20 00:07:42 +0000
commit8fe372c7b36b4d078c871a26e10b427c41275ecd (patch)
treefe6d3297c664404c2ee2347dba10b34d3249624c /test
parent2754d911641c3a4569f48d61c541fc2ac395d23b (diff)
downloadgo-8fe372c7b36b4d078c871a26e10b427c41275ecd.tar.gz
go-8fe372c7b36b4d078c871a26e10b427c41275ecd.zip
cmd/compile: allowing inlining of functions with OCALLPART
OCALLPART is exported in its original form, which is as an OXDOT. The body of the method value wrapper created in makepartialcall() was not being typechecked, and that was causing a problem during escape analysis, so I added code to typecheck the body. The go executable got slightly bigger with this change (13598111 -> 13598905), because of extra exported methods with OCALLPART (I believe), while the text size got slightly smaller (9686964 -> 9686643). This is mainly part of the work to make sure all function bodies can be exported (for purposes of generics), but might as well fix the OCALLPART inlining bug as well. Fixes #18493 Change-Id: If7aa055ff78ed7a6330c6a1e22f836ec567d04fd Reviewed-on: https://go-review.googlesource.com/c/go/+/263620 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'test')
-rw-r--r--test/inline.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/inline.go b/test/inline.go
index 0e41873de4..9b75bc5065 100644
--- a/test/inline.go
+++ b/test/inline.go
@@ -229,3 +229,20 @@ Loop:
}
}
}
+
+// Issue #18493 - make sure we can do inlining of functions with a method value
+type T1 struct{}
+
+func (a T1) meth(val int) int { // ERROR "can inline T1.meth" "inlining call to T1.meth"
+ return val + 5
+}
+
+func getMeth(t1 T1) func(int) int { // ERROR "can inline getMeth"
+ return t1.meth // ERROR "t1.meth escapes to heap"
+}
+
+func ii() { // ERROR "can inline ii"
+ var t1 T1
+ f := getMeth(t1) // ERROR "inlining call to getMeth" "t1.meth does not escape"
+ _ = f(3)
+}