]> Cypherpunks.ru repositories - gostls13.git/blobdiff - test/escape_iface.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / escape_iface.go
index 7b0914cadbbd006da0e5522d1e4b435a33b5a700..d822cca2f8485fa6b263cbb2db1599c9fcd4e0e1 100644 (file)
@@ -58,11 +58,10 @@ func efaceEscape0() {
                sink = v1
        }
        {
-               i := 0 // ERROR "moved to heap: i"
+               i := 0
                v := M0{&i}
-               // BAD: v does not escape to heap here
                var x M = v
-               x.M()
+               x.M() // ERROR "devirtualizing x.M"
        }
        {
                i := 0 // ERROR "moved to heap: i"
@@ -115,11 +114,10 @@ func efaceEscape1() {
                sink = v1 // ERROR "v1 escapes to heap"
        }
        {
-               i := 0 // ERROR "moved to heap: i"
+               i := 0
                v := M1{&i, 0}
-               // BAD: v does not escape to heap here
-               var x M = v // ERROR "v escapes to heap"
-               x.M()
+               var x M = v // ERROR "v does not escape"
+               x.M()       // ERROR "devirtualizing x.M"
        }
        {
                i := 0 // ERROR "moved to heap: i"
@@ -189,11 +187,10 @@ func efaceEscape2() {
                _ = ok
        }
        {
-               i := 0       // ERROR "moved to heap: i"
-               v := &M2{&i} // ERROR "&M2{...} escapes to heap"
-               // BAD: v does not escape to heap here
+               i := 0
+               v := &M2{&i} // ERROR "&M2{...} does not escape"
                var x M = v
-               x.M()
+               x.M() // ERROR "devirtualizing x.M"
        }
        {
                i := 0       // ERROR "moved to heap: i"
@@ -237,15 +234,15 @@ func dotTypeEscape2() { // #13805, #15796
                *(&v) = x.(int)
                *(&v), *(&ok) = y.(int)
        }
-       {
+       { // #13805, #15796
                i := 0
                j := 0
                var ok bool
                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"
-               sink, *(&ok) = y.(int)
+               sink = x.(int)         // ERROR "x.\(int\) escapes to heap"
+               sink, *(&ok) = y.(int) // ERROR "autotmp_.* escapes to heap"
        }
        {
                i := 0 // ERROR "moved to heap: i"
@@ -258,3 +255,11 @@ func dotTypeEscape2() { // #13805, #15796
                sink, *(&ok) = y.(*int)
        }
 }
+
+func issue42279() {
+       type I interface{ M() }
+       type T struct{ I }
+
+       var i I = T{} // ERROR "T\{\} does not escape"
+       i.M()         // ERROR "partially devirtualizing i.M to T"
+}