[box-tests] Added a reproducer for #KT-64139

This commit is contained in:
Igor Chevdar
2023-12-16 09:16:59 +02:00
committed by Space Team
parent 94c46d384a
commit 7907231bf2
20 changed files with 146 additions and 0 deletions
@@ -0,0 +1,33 @@
// WITH_STDLIB
// WITH_COROUTINES
import helpers.*
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.*
suspend fun suspendHere(): Unit = suspendCoroutineUninterceptedOrReturn { x ->
x.resume(Unit)
COROUTINE_SUSPENDED
}
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
class Data(val x: Int)
fun box(): String {
var result = ""
builder {
var data = Data(0)
var done = false
do {
data = Data(1)
suspendHere()
done = true
} while (!done)
result = if (data.x == 1) "OK" else "fail"
}
return result
}