Files
kotlin-fork/compiler/testData/codegen/boxInline/suspend/debugMetadataCrossinline.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

39 lines
762 B
Kotlin
Vendored

// WITH_STDLIB
// TARGET_BACKEND: JVM
// FILE: inline.kt
package test
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.*
fun runBlocking(c: suspend () -> Unit) {
c.startCoroutine(Continuation(EmptyCoroutineContext){
it.getOrThrow()
})
}
inline fun <reified E> foo(noinline block: (String) -> Unit) = runBlocking {
runCatching {
runBlocking {
var c: Continuation<Unit>? = null
suspendCoroutineUninterceptedOrReturn<Unit> { c = it; Unit }
block(c!!.toString())
}
}
Unit
}
// FILE: test.kt
import test.*
fun box(): String {
var res = "FAIL"
foo<Exception> {
res = it
}
return if (res.contains(".invokeSuspend(inline.kt:")) "OK" else res
}