FIR2IR: Fix substitution work for context receivers
This commit is contained in:
Vendored
+29
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user