Files
kotlin-fork/compiler/testData/codegen/boxInline/smap/crossroutines.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

51 lines
961 B
Kotlin
Vendored

// This test depends on line numbers
// WITH_STDLIB
// FILE: 1.kt
package test
interface SuspendRunnable {
suspend fun run()
}
inline suspend fun inlineMe1(crossinline c: suspend () -> Unit): SuspendRunnable =
object : SuspendRunnable {
override suspend fun run() {
c()
}
}
inline suspend fun inlineMe2(crossinline c: suspend () -> Unit): suspend () -> Unit =
{
c()
}
// FILE: 2.kt
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.*
import test.*
fun builder(c: suspend () -> Unit) {
c.startCoroutine(object: Continuation<Unit> {
override val context = EmptyCoroutineContext
override fun resumeWith(result: Result<Unit>) {
result.getOrThrow()
}
})
}
fun box(): String {
var res = ""
builder {
inlineMe1 {
res += "O"
}.run()
inlineMe2 {
res += "K"
}()
}
return res
}