Files
kotlin-fork/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessOperators.kt
T
Sergej Jaskiewicz f2031ae642 [IR] Don't print multifile/synthetic facade class names in irText tests
This only applies to JVM and fq-names in declaration references
in IR dumps.

This enables us to run more irText tests on platforms other than JVM
(see KT-58605).
2023-06-05 10:40:17 +00:00

23 lines
490 B
Kotlin
Vendored

// !LANGUAGE: +ContextReceivers
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"
}
}