FIR2IR: Fix substitution work for context receivers

This commit is contained in:
Denis.Zharkov
2022-05-05 11:14:26 +03:00
committed by teamcity
parent 9ec2411218
commit b87412c5af
12 changed files with 192 additions and 23 deletions
@@ -0,0 +1,29 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
class Box<E>(val x: E)
class A<X, Y> {
context(Box<X>, Y)
fun foo(): String = x.toString() + this@Y.toString()
context(Box<X>, Y)
val p1: String get() = x.toString() + this@Y.toString()
}
context(Box<X>, Y)
fun <X, Y> bar(): String = x.toString() + this@Y.toString()
fun box(): String {
return with(Box("OK")) {
with(56) {
val a = A<String, Int>()
if (a.foo() != "OK56") return "fail 1"
if (a.p1 != "OK56") return "fail 2"
val b = bar<String, Int>()
if (b != "OK56") return "fail 3"
return "OK"
}
}
}
@@ -0,0 +1,18 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
class Components(val x: String)
context(Components)
abstract class A<F : CharSequence>(val y: F) {
fun foo(): String = x + y
}
context(Components)
class B(y: String) : A<String>(y)
fun box(): String {
return with(Components("O")) {
B("K").foo()
}
}