JS: fix coroutine transformation of callable references to local functions. See KT-16164

This commit is contained in:
Alexey Andreev
2017-03-01 18:22:34 +03:00
parent 18fb70b32f
commit 8567db10b5
6 changed files with 93 additions and 5 deletions
@@ -0,0 +1,24 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.experimental.*
import kotlin.coroutines.experimental.intrinsics.*
suspend fun suspendWithValue(result: () -> String): String = suspendCoroutineOrReturn { x ->
x.resume(result())
COROUTINE_SUSPENDED
}
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
fun box(): String {
var result = ""
builder {
fun ok() = "OK"
result = suspendWithValue(::ok)
}
return result
}