Perform fix-stack transformation before method analysis

Otherwise it might fail on an "invalid" bytecode
This commit is contained in:
Denis Zharkov
2017-05-12 15:50:10 +03:00
parent dcaad530ce
commit e75b6c8404
6 changed files with 83 additions and 3 deletions
@@ -0,0 +1,40 @@
// WITH_RUNTIME
// WITH_COROUTINES
// IGNORE_BACKEND: NATIVE
import helpers.*
import kotlin.coroutines.experimental.*
import kotlin.coroutines.experimental.intrinsics.*
class A {
var result = mutableListOf("O", "K", null)
suspend fun foo(): String? = suspendCoroutineOrReturn { x ->
x.resume(result.removeAt(0))
COROUTINE_SUSPENDED
}
}
var result = ""
suspend fun append(ignore: String, x: String) {
result += x
}
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
suspend fun bar() {
val a = A()
while (true) {
append("ignore", a.foo() ?: break)
}
}
fun box(): String {
builder {
bar()
}
return result
}