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

23 lines
530 B
Kotlin
Vendored

// WITH_STDLIB
// WITH_COROUTINES
// TARGET_BACKEND: JVM
// FILE: a.kt
inline suspend fun f(crossinline lambda: suspend (Double) -> Double): Double {
val obj = object {
suspend fun g(x: Double): Double = lambda(x)
}
return obj.g(1.0)
}
// FILE: b.kt
import helpers.*
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.*
fun box(): String {
var result: Double = 0.0
suspend { result = f { it } }.startCoroutine(EmptyContinuation)
return if (result == 1.0) "OK" else "fail: $result"
}