Obtain correct captured suspend local function

if we call the function inside, for example, lambda.
 #KT-28844 Fixed
This commit is contained in:
Ilmir Usmanov
2018-12-18 14:57:32 +03:00
parent ac5f5bd453
commit 10f0a2f660
7 changed files with 93 additions and 5 deletions
+39
View File
@@ -0,0 +1,39 @@
// WITH_RUNTIME
// WITH_COROUTINES
// COMMON_COROUTINES_TEST
// IGNORE_BACKEND: JVM_IR, NATIVE
import helpers.*
import COROUTINES_PACKAGE.*
fun builder(block: suspend Unit.() -> Unit) {
block.startCoroutine(Unit, EmptyContinuation)
}
var res = "FAIL 1"
fun testOuterJobIsCancelled() = builder {
suspend fun callJobScoped() = "OK"
val outerJob = suspend {
res = callJobScoped()
}
outerJob()
}
fun testOuterJobIsCancelled2() = builder {
suspend fun callJobScoped() = "OK"
suspend fun outerJob() {
res = callJobScoped()
}
outerJob()
}
fun box(): String {
testOuterJobIsCancelled()
if (res != "OK") return res
res = "FAIL 2"
testOuterJobIsCancelled2()
return res
}