Allow destructuring in suspend lambda with suspend componentX

#KT-16113 Fixed
This commit is contained in:
Denis Zharkov
2017-02-02 10:58:29 +03:00
parent 59fe7444d1
commit 60c2579436
12 changed files with 132 additions and 8 deletions
@@ -0,0 +1,26 @@
// WITH_RUNTIME
// WITH_COROUTINES
// IGNORE_BACKEND: JS
import kotlin.coroutines.experimental.*
import kotlin.coroutines.experimental.intrinsics.*
data class A(val o: String) {
operator suspend fun component2(): String = suspendCoroutineOrReturn { x ->
x.resume("K")
COROUTINE_SUSPENDED
}
}
fun builder(c: suspend (A) -> Unit) {
(c as (suspend A.() -> Unit)).startCoroutine(A("O"), EmptyContinuation)
}
fun box(): String {
var result = ""
builder {
(x, y) ->
result = x + y
}
return result
}