[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
This commit is contained in:
Kirill Rakhman
2023-02-21 16:24:34 +01:00
committed by Space Team
parent 5ecf9cce25
commit 3b9724d20e
77 changed files with 1171 additions and 553 deletions
@@ -81,9 +81,12 @@ FILE: CanBeValChecker.kt
when () {
R|<local>/flag| -> {
while(CMP(>, R|<local>/a|.R|kotlin/Int.compareTo|(Int(0)))) {
lval <unary>: R|kotlin/Int| = R|<local>/a|
R|<local>/a| = R|<local>/<unary>|.R|kotlin/Int.dec|()
R|<local>/<unary>|
{
lval <unary>: R|kotlin/Int| = R|<local>/a|
R|<local>/a| = R|<local>/<unary>|.R|kotlin/Int.dec|()
R|<local>/<unary>|
}
}
}
@@ -111,17 +114,23 @@ FILE: CanBeValChecker.kt
lvar v2: R|kotlin/Int| = Int(2)
lvar v3: R|kotlin/Int| = Int(3)
R|<local>/v1| = Int(1)
lval <unary>: R|kotlin/Int| = R|<local>/v2|
R|<local>/v2| = R|<local>/<unary>|.R|kotlin/Int.inc|()
R|<local>/<unary>|
{
lval <unary>: R|kotlin/Int| = R|<local>/v2|
R|<local>/v2| = R|<local>/<unary>|.R|kotlin/Int.inc|()
R|<local>/<unary>|
}
R|kotlin/io/print|(R|<local>/v3|)
}
public final fun test(): R|kotlin/Unit| {
lvar a: R|kotlin/Int| = Int(0)
while(CMP(>, R|<local>/a|.R|kotlin/Int.compareTo|(Int(0)))) {
lval <unary>: R|kotlin/Int| = R|<local>/a|
R|<local>/a| = R|<local>/<unary>|.R|kotlin/Int.inc|()
R|<local>/<unary>|
{
lval <unary>: R|kotlin/Int| = R|<local>/a|
R|<local>/a| = R|<local>/<unary>|.R|kotlin/Int.inc|()
R|<local>/<unary>|
}
}
}
@@ -143,16 +152,22 @@ FILE: CanBeValChecker.kt
public final fun cycles(): R|kotlin/Unit| {
lvar a: R|kotlin/Int| = Int(10)
while(CMP(>, R|<local>/a|.R|kotlin/Int.compareTo|(Int(0)))) {
lval <unary>: R|kotlin/Int| = R|<local>/a|
R|<local>/a| = R|<local>/<unary>|.R|kotlin/Int.dec|()
R|<local>/<unary>|
{
lval <unary>: R|kotlin/Int| = R|<local>/a|
R|<local>/a| = R|<local>/<unary>|.R|kotlin/Int.dec|()
R|<local>/<unary>|
}
}
lvar b: R|kotlin/Int|
while(CMP(<, R|<local>/a|.R|kotlin/Int.compareTo|(Int(10)))) {
lval <unary>: R|kotlin/Int| = R|<local>/a|
R|<local>/a| = R|<local>/<unary>|.R|kotlin/Int.inc|()
R|<local>/<unary>|
{
lval <unary>: R|kotlin/Int| = R|<local>/a|
R|<local>/a| = R|<local>/<unary>|.R|kotlin/Int.inc|()
R|<local>/<unary>|
}
R|<local>/b| = R|<local>/a|
}