Files
kotlin-fork/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessCompositeOperators.kt
T
Sergej Jaskiewicz 1a29b9efff [FIR, IR] Fix name mangling for functions with context receivers
- Mangled names of property accessors now include context receiver
  types of the corresponding property when computed from FIR.
- Context receivers are now supported when computing mangled names
  from IR
- IrBasedDescriptors now account for context receivers

^KT-57435 Fixed
2023-05-23 08:55:50 +00:00

33 lines
702 B
Kotlin
Vendored

// !LANGUAGE: +ContextReceivers
// IGNORE_BACKEND: JS_IR
data class MyContainer(var i: Int)
var operationScore = 0
context(Int)
operator fun MyContainer.get(index: Int): Int {
operationScore += this@Int
return if (index == 0) i else -1
}
context(Int)
operator fun MyContainer.plusAssign(other: MyContainer) {
operationScore += this@Int
i += other.i
}
context(Int)
operator fun MyContainer.inc(): MyContainer {
operationScore += this@Int
return MyContainer(i + 1)
}
fun box(): String {
var myContainer = MyContainer(0)
with(1) {
myContainer += MyContainer(myContainer++[0])
}
return if (myContainer.i == 1 && operationScore == 3) "OK" else "fail"
}