c7435ba760
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.
51 lines
961 B
Kotlin
Vendored
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
|
|
}
|
|
|