blob: 9fb2c72b469ee9f9bf3ab1f5e7288499879c44ca [file]
// WITH_STDLIB
// ISSUE: KT-68849
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()
}
}