FIR2IR: fix origin calculation for explicit inc/dec calls

This commit is contained in:
Mikhail Glukhikh
2023-07-10 11:51:32 +02:00
committed by Space Team
parent f8ca440e96
commit 39406710b2
12 changed files with 102 additions and 23 deletions
@@ -0,0 +1,16 @@
FILE fqName:<root> fileName:/explicitIncrement.kt
FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
VAR name:i type:kotlin.Int [var]
CONST Int type=kotlin.Int value=1
WHILE label=null origin=WHILE_LOOP
condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT
arg0: GET_VAR 'var i: kotlin.Int declared in <root>.foo' type=kotlin.Int origin=null
arg1: CONST Int type=kotlin.Int value=10
body: BLOCK type=kotlin.Unit origin=null
CALL 'public final fun bar (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
SET_VAR 'var i: kotlin.Int declared in <root>.foo' type=kotlin.Unit origin=EQ
CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
$this: GET_VAR 'var i: kotlin.Int declared in <root>.foo' type=kotlin.Int origin=null
FUN name:bar visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
@@ -0,0 +1,10 @@
// FIR_IDENTICAL
fun foo() {
var i = 1
while (i < 10) {
bar()
i = i.inc()
}
}
fun bar() {}
@@ -0,0 +1,11 @@
fun foo() {
var i: Int = 1
while (less(arg0 = i, arg1 = 10)) { // BLOCK
bar()
i = i.inc()
}
}
fun bar() {
}
@@ -0,0 +1,10 @@
// CHECK:
// Mangled name: #bar(){}
// Public signature: /bar|496682602797471549[0]
fun bar(): Unit
// CHECK:
// Mangled name: #foo(){}
// Public signature: /foo|-1041209573719867811[0]
fun foo(): Unit