summaryrefslogtreecommitdiff
path: root/test/escape_iface_unified.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2022-06-28 16:31:29 -0700
committerMatthew Dempsky <mdempsky@google.com>2022-06-30 18:42:24 +0000
commit3635b07d16c9fe3f344b3271fb3bf7029d8b4001 (patch)
treea3aa4eb2bc357656521d274417946ca2b7d9944e /test/escape_iface_unified.go
parente7219cc093aca07bdb7179fa1a42d44e56eaf9d4 (diff)
downloadgo-git-3635b07d16c9fe3f344b3271fb3bf7029d8b4001.tar.gz
[dev.unified] cmd/compile/internal/noder: implicit conversions for multi-valued expressions
This CL changes GOEXPERIMENT=unified to insert implicit conversions for multi-valued expressions. Unfortunately, IR doesn't have strong, first-class support for multi-valued expressions, so this CL takes the approach of spilling them to temporary variables, which can then be implicitly converted. This is the same approach taken by walk, but doing it this early does introduce some minor complications: 1. For select case clauses with comma-ok assignments (e.g., `case x, ok := <-ch:`), the compiler middle end wants to see the OAS2RECV assignment is the CommClause.Comm statement. So when constructing select statements, we need to massage this around a little. 2. The extra temporary variables and assignments skew the existing inlining heuristics. As mentioned, the temporaries/assignments will eventually be added (and often optimized away again) anyway, but now they're visible to the inliner. So this CL also kludges the inlining heuristics in this case to keep things comparable. Change-Id: I3e3ea756ad92472ebe28bae3963be61ed7684a75 Reviewed-on: https://go-review.googlesource.com/c/go/+/415244 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'test/escape_iface_unified.go')
-rw-r--r--test/escape_iface_unified.go5
1 files changed, 2 insertions, 3 deletions
diff --git a/test/escape_iface_unified.go b/test/escape_iface_unified.go
index 7ac8e00151..80222dae5f 100644
--- a/test/escape_iface_unified.go
+++ b/test/escape_iface_unified.go
@@ -18,8 +18,7 @@ func dotTypeEscape2() { // #13805, #15796
var x interface{} = i // ERROR "i does not escape"
var y interface{} = j // ERROR "j does not escape"
- sink = x.(int) // ERROR "x.\(int\) escapes to heap"
- // BAD: should be "y.\(int\) escapes to heap" too
- sink, *(&ok) = y.(int)
+ sink = x.(int) // ERROR "x.\(int\) escapes to heap"
+ sink, *(&ok) = y.(int) // ERROR "autotmp_.* escapes to heap"
}
}