Files
kotlin-fork/compiler/testData/ir/irText/expressions/complexAugmentedAssignment.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

104 lines
1.6 KiB
Kotlin
Vendored

object X1 {
private constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
var x1: Int
field = 0
get
set
object X2 {
private constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
var x2: Int
field = 0
get
set
object X3 {
private constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
var x3: Int
field = 0
get
set
}
}
}
fun test1(a: IntArray) {
var i: Int = 0
val <array>: IntArray = a
val <index_0>: Int = { // BLOCK
val <unary>: Int = i
i = <unary>.inc()
<unary>
}
val <unary>: Int = <array>.get(index = <index_0>)
<array>.set(index = <index_0>, value = <unary>.inc())
<unary> /*~> Unit */
}
fun test2() {
{ // BLOCK
val <unary>: Int = X1.<get-x1>()
X1.<set-x1>(<set-?> = <unary>.inc())
<unary>
} /*~> Unit */
{ // BLOCK
val <unary>: Int = X2.<get-x2>()
X2.<set-x2>(<set-?> = <unary>.inc())
<unary>
} /*~> Unit */
{ // BLOCK
val <unary>: Int = X3.<get-x3>()
X3.<set-x3>(<set-?> = <unary>.inc())
<unary>
} /*~> Unit */
}
class B {
constructor(s: Int = 0) /* primary */ {
super/*Any*/()
/* <init>() */
}
var s: Int
field = s
get
set
}
object Host {
private constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
operator fun B.plusAssign(b: B) {
<this>.<set-s>(<set-?> = <this>.<get-s>().plus(other = b.<get-s>()))
}
}
fun Host.test3(v: B) {
(<this>, v).plusAssign(b = B(s = 1000))
}