blob: f628a0c8207a5a0ba20d98c70a0e7d475ebbd344 [file]
// LANGUAGE: +ContextParameters
// IGNORE_BACKEND_K1: ANY
// WITH_STDLIB
// WITH_COROUTINES
class InContext
class MyReciever {
public suspend fun MyOutput.innerFun(): Int = 123
}
class MyOutput
// 2 - Declare the caller that calls the suspended function in a context
public fun caller(block: suspend context(InContext) MyReciever.() -> Int): MyOutput = MyOutput()
fun box(): String {
val out1 = caller { MyOutput().innerFun() }
val out2 = with (InContext()) { caller { MyOutput().innerFun() } }
val out3 = caller { with (InContext()) { MyOutput().innerFun() } }
return "OK"
}