Files
kotlin-fork/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.fir.kt.txt
T
Kirill Rakhman 3b9724d20e [FIR] Desugar increment/decrement in body resolve phase
The expression needs to be resolved first to determine if there is a
receiver that needs to be extracted to a temporary variable. Also, the
special case for prefix increment/decrement on local variable without
delegates requires resolution to check if the variable is local.

^KT-56771 Fixed
^KT-56659 Fixed
2023-03-02 10:19:57 +00:00

65 lines
1.2 KiB
Kotlin
Vendored

package test
class C {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
}
var C?.p: Int
get(): Int {
return 42
}
set(value: Int) {
}
operator fun Int?.inc(): Int? {
return { // BLOCK
val tmp0_safe_receiver: Int? = <this>
when {
EQEQ(arg0 = tmp0_safe_receiver, arg1 = null) -> null
else -> tmp0_safe_receiver.inc()
}
}
}
operator fun Int?.get(index: Int): Int {
return 42
}
operator fun Int?.set(index: Int, value: Int) {
}
fun testProperty(nc: C?) {
{ // BLOCK
val tmp1_safe_receiver: C? = nc
when {
EQEQ(arg0 = tmp1_safe_receiver, arg1 = null) -> null
else -> { // BLOCK
val <unary>: Int = tmp1_safe_receiver.<get-p>()
tmp1_safe_receiver.<set-p>(value = <unary>.inc())
<unary>
}
}
} /*~> Unit */
}
fun testArrayAccess(nc: C?) {
{ // BLOCK
val tmp2_safe_receiver: C? = nc
when {
EQEQ(arg0 = tmp2_safe_receiver, arg1 = null) -> null
else -> { // BLOCK
val <array>: Int = tmp2_safe_receiver.<get-p>()
val <index_0>: Int = 0
val <unary>: Int = <array>.get(index = <index_0>)
<array>.set(index = <index_0>, value = <unary>.inc())
<unary>
}
}
} /*~> Unit */
}