[Tests] Make sure desugaring works with context receivers
This commit is contained in:
committed by
TeamCityServer
parent
0bfea4fc52
commit
4d0eb74d79
+24
@@ -0,0 +1,24 @@
|
||||
// !LANGUAGE: +ContextReceivers
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
data class MyContainer(var s: String)
|
||||
|
||||
context(Int)
|
||||
operator fun MyContainer.get(index: Int): String? {
|
||||
return if (index == 0 && this@Int == 42) s else null
|
||||
}
|
||||
|
||||
context(Int)
|
||||
operator fun MyContainer.set(index: Int, value: String) {
|
||||
if (index != 0 || this@Int != 42) return
|
||||
s = value
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return with(42) {
|
||||
val myContainer = MyContainer("fail")
|
||||
myContainer[0] = "OK"
|
||||
myContainer[0] ?: "fail"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user