Implement missing invoke resolution branch with context receivers
#KT-61937 fixed Note: the current implementation only resolves for a single receiver in each group. See KT-62712 and KT-62709 for the followup.
This commit is contained in:
committed by
Space Team
parent
b89d8a65a1
commit
268d058bbb
@@ -0,0 +1,22 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// IGNORE_BACKEND_K1: ANY
|
||||
// !LANGUAGE: +ContextReceivers
|
||||
|
||||
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"
|
||||
}
|
||||
Reference in New Issue
Block a user