Minor. Add test on local vars of suspend function type

This commit is contained in:
Denis Zharkov
2017-01-11 20:35:10 +03:00
parent 7837d736f7
commit 695b6d9e67
6 changed files with 127 additions and 0 deletions
@@ -0,0 +1,34 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.*
suspend fun suspendHere(v: String): String = suspendCoroutineOrReturn { x ->
x.resume(v)
SUSPENDED_MARKER
}
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
suspend fun foo(): String {
var a = "OK"
var i = 0
val x: suspend () -> String = {
suspendHere(a[i++].toString())
}
return x() + x.invoke()
}
fun box(): String {
var result = ""
builder {
result = foo()
}
return result
}