blob: 0521d9864f4a47c121ea092a48f6c6b69e749d83 [file]
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K1: ANY
// IGNORE_BACKEND_K2: ANY
// LANGUAGE: +ContextReceivers, -ContextParameters
class Ctx(val value: Int)
fun Ctx.foo() = value + 4
context(Ctx)
class A {
fun bar(body: Ctx.() -> Int): Int {
return foo() *
body()
}
}
fun box(): String {
val res = with(Ctx(3)) {
A().bar { this.value * 2 }
}
return if (res == 42) "OK" else "NOK: $res"
}