Make 'controller' field package-private
To make it accessible from nested lambdas #KT-12974 Fixed
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
class Controller {
|
||||
var result = false
|
||||
suspend fun suspendHere(x: Continuation<String>) {
|
||||
x.resume("OK")
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
result = true
|
||||
}
|
||||
}
|
||||
|
||||
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
|
||||
val controller = Controller()
|
||||
c(controller).resume(Unit)
|
||||
if (!controller.result) throw java.lang.RuntimeException("fail")
|
||||
}
|
||||
|
||||
fun noinlineRun(block: () -> Unit) {
|
||||
block()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
builder {
|
||||
if (suspendHere() != "OK") {
|
||||
throw java.lang.RuntimeException("fail 1")
|
||||
}
|
||||
noinlineRun {
|
||||
foo()
|
||||
}
|
||||
|
||||
if (suspendHere() != "OK") {
|
||||
throw java.lang.RuntimeException("fail 2")
|
||||
}
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user