aboutsummaryrefslogtreecommitdiff
path: root/test/closure3.dir
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2021-03-12 12:57:39 -0800
committerKeith Randall <khr@golang.org>2021-04-10 14:58:18 +0000
commit1129a60f1c1e64147ca1133857c4571ce9b87a35 (patch)
tree6ea37d4fb479f7009ccf43aacc07a547db7e7287 /test/closure3.dir
parent11f159456b1dba3ec499da916852dd188d1e04a7 (diff)
downloadgo-1129a60f1c1e64147ca1133857c4571ce9b87a35.tar.gz
go-1129a60f1c1e64147ca1133857c4571ce9b87a35.zip
cmd/compile: include typecheck information in export/import
Include type information on exported function bodies, so that the importer does not have to re-typecheck the body. This involves including type information in the encoded output, as well as avoiding some of the opcode rewriting and other changes that the old exporter did assuming there would be a re-typechecking pass. This CL could be considered a cleanup, but is more important than that because it is an enabling change for generics. Without this CL, we'd have to upgrade the current typechecker to understand generics. With this CL, the current typechecker can mostly go away in favor of the types2 typechecker. For now, inlining of functions that contain closures is turned off. We will hopefully resolve this before freeze. Object files are only 0.07% bigger. Change-Id: I85c9da09f66bfdc910dc3e26abb2613a1831634d Reviewed-on: https://go-review.googlesource.com/c/go/+/301291 Trust: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Reviewed-by: Dan Scales <danscales@google.com>
Diffstat (limited to 'test/closure3.dir')
-rw-r--r--test/closure3.dir/main.go44
1 files changed, 22 insertions, 22 deletions
diff --git a/test/closure3.dir/main.go b/test/closure3.dir/main.go
index 2fc33753ed..e8e1e99860 100644
--- a/test/closure3.dir/main.go
+++ b/test/closure3.dir/main.go
@@ -93,11 +93,11 @@ func main() {
y := func(x int) int { // ERROR "can inline main.func11" "func literal does not escape"
return x + 2
}
- y, sink = func() (func(int) int, int) { // ERROR "can inline main.func12"
- return func(x int) int { // ERROR "can inline main.func12"
+ y, sink = func() (func(int) int, int) { // ERROR "func literal does not escape"
+ return func(x int) int { // ERROR "can inline main.func12" "func literal escapes"
return x + 1
}, 42
- }() // ERROR "func literal does not escape" "inlining call to main.func12"
+ }()
if y(40) != 41 {
ppanic("y(40) != 41")
}
@@ -105,14 +105,14 @@ func main() {
{
func() { // ERROR "func literal does not escape"
- y := func(x int) int { // ERROR "func literal does not escape" "can inline main.func13.1"
+ y := func(x int) int { // ERROR "can inline main.func13.1" "func literal does not escape"
return x + 2
}
- y, sink = func() (func(int) int, int) { // ERROR "can inline main.func13.2"
- return func(x int) int { // ERROR "can inline main.func13.2"
+ y, sink = func() (func(int) int, int) { // ERROR "func literal does not escape"
+ return func(x int) int { // ERROR "can inline main.func13.2" "func literal escapes"
return x + 1
}, 42
- }() // ERROR "inlining call to main.func13.2" "func literal does not escape"
+ }()
if y(40) != 41 {
ppanic("y(40) != 41")
}
@@ -187,29 +187,29 @@ func main() {
{
x := 42
- if z := func(y int) int { // ERROR "can inline main.func22"
- return func() int { // ERROR "can inline main.func22.1" "can inline main.func30"
+ if z := func(y int) int { // ERROR "func literal does not escape"
+ return func() int { // ERROR "can inline main.func22.1"
return x + y
}() // ERROR "inlining call to main.func22.1"
- }(1); z != 43 { // ERROR "inlining call to main.func22" "inlining call to main.func30"
+ }(1); z != 43 {
ppanic("z != 43")
}
- if z := func(y int) int { // ERROR "func literal does not escape" "can inline main.func23"
- return func() int { // ERROR "can inline main.func23.1" "can inline main.func31"
+ if z := func(y int) int { // ERROR "func literal does not escape"
+ return func() int { // ERROR "can inline main.func23.1"
return x + y
}() // ERROR "inlining call to main.func23.1"
- }; z(1) != 43 { // ERROR "inlining call to main.func23" "inlining call to main.func31"
+ }; z(1) != 43 {
ppanic("z(1) != 43")
}
}
{
a := 1
- func() { // ERROR "can inline main.func24"
- func() { // ERROR "can inline main.func24" "can inline main.func32"
+ func() { // ERROR "func literal does not escape"
+ func() { // ERROR "can inline main.func24"
a = 2
}() // ERROR "inlining call to main.func24"
- }() // ERROR "inlining call to main.func24" "inlining call to main.func32"
+ }()
if a != 2 {
ppanic("a != 2")
}
@@ -250,12 +250,12 @@ func main() {
a := 2
if r := func(x int) int { // ERROR "func literal does not escape"
b := 3
- return func(y int) int { // ERROR "can inline main.func27.1"
+ return func(y int) int { // ERROR "func literal does not escape"
c := 5
- return func(z int) int { // ERROR "can inline main.func27.1.1" "can inline main.func27.2"
+ return func(z int) int { // ERROR "can inline main.func27.1.1"
return a*x + b*y + c*z
}(10) // ERROR "inlining call to main.func27.1.1"
- }(100) // ERROR "inlining call to main.func27.1" "inlining call to main.func27.2"
+ }(100)
}(1000); r != 2350 {
ppanic("r != 2350")
}
@@ -265,15 +265,15 @@ func main() {
a := 2
if r := func(x int) int { // ERROR "func literal does not escape"
b := 3
- return func(y int) int { // ERROR "can inline main.func28.1"
+ return func(y int) int { // ERROR "func literal does not escape"
c := 5
- func(z int) { // ERROR "can inline main.func28.1.1" "can inline main.func28.2"
+ func(z int) { // ERROR "can inline main.func28.1.1"
a = a * x
b = b * y
c = c * z
}(10) // ERROR "inlining call to main.func28.1.1"
return a + c
- }(100) + b // ERROR "inlining call to main.func28.1" "inlining call to main.func28.2"
+ }(100) + b
}(1000); r != 2350 {
ppanic("r != 2350")
}