Provide access to 'coroutineContext' inside suspend functions/lambdas (KT-24829)

This commit is contained in:
Yan Zhulanow
2018-12-13 19:37:08 +09:00
parent cf925fc2ad
commit 227a7e5609
8 changed files with 145 additions and 1 deletions
@@ -0,0 +1,15 @@
package coroutineContextFun
import kotlin.coroutines.coroutineContext
suspend fun main() {
val a = 5
foo()
//Breakpoint!
foo()
}
private suspend fun foo() {}
// EXPRESSION: coroutineContext
// RESULT: instance of kotlin.coroutines.EmptyCoroutineContext(id=ID): Lkotlin/coroutines/EmptyCoroutineContext;
@@ -0,0 +1,8 @@
LineBreakpoint created at coroutineContextFun.kt:9
Run Java
Connected to the target VM
coroutineContextFun.kt:9
Compile bytecode for coroutineContext
Disconnected from the target VM
Process finished with exit code 0
@@ -0,0 +1,19 @@
package coroutineContextLambda
import kotlin.coroutines.coroutineContext
suspend fun main() {
foo()
}
private var foo: suspend () -> Unit = {
bar()
}
private var bar: suspend () -> Unit = {
//Breakpoint!
val a = 5
}
// EXPRESSION: coroutineContext
// RESULT: instance of kotlin.coroutines.EmptyCoroutineContext(id=ID): Lkotlin/coroutines/EmptyCoroutineContext;
@@ -0,0 +1,8 @@
LineBreakpoint created at coroutineContextLambda.kt:15
Run Java
Connected to the target VM
coroutineContextLambda.kt:15
Compile bytecode for coroutineContext
Disconnected from the target VM
Process finished with exit code 0