JS: fix translation of delegated local variables in coroutines. See KT-15834

This commit is contained in:
Alexey Andreev
2017-01-23 15:20:11 +03:00
parent 8040d781b4
commit 26a3ac5a9b
7 changed files with 94 additions and 0 deletions
@@ -0,0 +1,29 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.SUSPENDED_MARKER
import kotlin.coroutines.intrinsics.suspendCoroutineOrReturn
class OkDelegate {
operator fun getValue(receiver: Any?, property: Any?): String = "OK"
}
suspend fun <T> suspendWithValue(value: T): T = suspendCoroutineOrReturn { c ->
c.resume(value)
SUSPENDED_MARKER
}
fun launch(c: suspend () -> String): String {
var result: String = "fail: result not assigned"
c.startCoroutine(handleResultContinuation { value ->
result = value
})
return result
}
fun box(): String {
return launch {
val ok by OkDelegate()
ok
}
}