blob: f72dc99f0299d94d7b5d34ec2cfb6d45741073f6 [file]
// WITH_STDLIB
// ISSUE: KT-68849
// IGNORE_KLIB_RUNTIME_ERRORS_WITH_CUSTOM_FIRST_STAGE: Native:2.0
// IGNORE_KLIB_BACKEND_ERRORS_WITH_CUSTOM_FIRST_STAGE: JS,Wasm-JS:2.0
// ^^^ KT-68849 fixed in 2.0.20-Beta2
import kotlin.coroutines.Continuation
import kotlin.coroutines.EmptyCoroutineContext
import kotlin.coroutines.startCoroutine
fun interface SuspendFun {
suspend fun method(): String
}
fun <T> runBlocking(c: suspend () -> T): T {
var res: T? = null
c.startCoroutine(Continuation(EmptyCoroutineContext) {
res = it.getOrThrow()
})
return res!!
}
fun box(): String {
val impl: () -> String = { "OK" }
val suspendImpl = SuspendFun(impl)
return runBlocking {
suspendImpl.method()
}
}