Files
kotlin/compiler/testData/codegen/bytecodeText/coroutines/varValueConflictsWithTable.kt
Denis Zharkov 1f98accad2 Support new suspend convention in JVM backend partially
Stack-unwinding does not work yet

 #KT-14924 In Progress
2016-11-29 14:14:50 +03:00

43 lines
1.1 KiB
Kotlin
Vendored

class Controller {
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK")
}
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
c(Controller()).resume(Unit)
}
fun box(): String {
var result = "fail 1"
builder {
// Initialize var with Int value
for (i in 1..1) {
if ("".length > 0) continue
}
// This variable should take the same slot as 'i' had
var s: String
// We should not spill 's' to continuation field because it's not initialized
// More precisely it contains a value of wrong type (it conflicts with contents of local var table),
// so an attempt of spilling may lead to problems on Android
if (suspendHere() == "OK") {
s = "OK"
}
else {
s = "fail 2"
}
result = s
}
return result
}
// 1 LOCALVARIABLE i I L.* 3
// 1 LOCALVARIABLE s Ljava/lang/String; L.* 3
// 0 PUTFIELD VarValueConflictsWithTableKt\$box\$1.I\$0 : I
/* 2 loads in cycle */
// 2 ILOAD 3