Set correct IR origins for inc/dec operations

NB: in order to produce correct IR origins, the source element kinds for
some FIR elements has been changed. As a side effect, mapping PSI to FIR
slightly changed: namely, for `a[b]++`, `a[b]` used to be mapped on
`set` call or callable reference, but now it is mapped on `get` call.

^KT-61891: Fixed
^KT-64387: Fixed
This commit is contained in:
vladislav.grechko
2023-12-28 17:12:17 +01:00
committed by Space Team
parent 8b1d87848d
commit 9aa8fb80e7
65 changed files with 463 additions and 972 deletions
@@ -182,11 +182,11 @@ FILE fqName:<root> fileName:/arrayAccessCompositeOperators.kt
$context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in <root>.box.<anonymous>' type=kotlin.Int origin=null
other: CONSTRUCTOR_CALL 'public constructor <init> (i: kotlin.Int) declared in <root>.MyContainer' type=<root>.MyContainer origin=null
i: CALL 'public final fun get ($context_receiver_0: kotlin.Int, index: kotlin.Int): kotlin.Int declared in <root>' type=kotlin.Int origin=null
$receiver: BLOCK type=<root>.MyContainer origin=null
$receiver: BLOCK type=<root>.MyContainer origin=POSTFIX_INCR
VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:<root>.MyContainer [val]
GET_VAR 'var myContainer: <root>.MyContainer declared in <root>.box' type=<root>.MyContainer origin=null
SET_VAR 'var myContainer: <root>.MyContainer declared in <root>.box' type=kotlin.Unit origin=EQ
CALL 'public final fun inc ($context_receiver_0: kotlin.Int): <root>.MyContainer declared in <root>' type=<root>.MyContainer origin=null
GET_VAR 'var myContainer: <root>.MyContainer declared in <root>.box' type=<root>.MyContainer origin=POSTFIX_INCR
SET_VAR 'var myContainer: <root>.MyContainer declared in <root>.box' type=kotlin.Unit origin=POSTFIX_INCR
CALL 'public final fun inc ($context_receiver_0: kotlin.Int): <root>.MyContainer declared in <root>' type=<root>.MyContainer origin=POSTFIX_INCR
$receiver: GET_VAR 'val tmp_1: <root>.MyContainer declared in <root>.box.<anonymous>' type=<root>.MyContainer origin=null
$context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in <root>.box.<anonymous>' type=kotlin.Int origin=null
GET_VAR 'val tmp_1: <root>.MyContainer declared in <root>.box.<anonymous>' type=<root>.MyContainer origin=null
@@ -231,16 +231,16 @@ FILE fqName:<root> fileName:/iteratorOperator.kt
$this: VALUE_PARAMETER name:<this> type:<root>.CounterIterator
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun next (): kotlin.Int declared in <root>.CounterIterator'
BLOCK type=kotlin.Int origin=null
BLOCK type=kotlin.Int origin=POSTFIX_INCR
VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:<root>.Counter [val]
CALL 'private final fun <get-counter> (): <root>.Counter declared in <root>.CounterIterator' type=<root>.Counter origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.CounterIterator declared in <root>.CounterIterator.next' type=<root>.CounterIterator origin=null
VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val]
CALL 'public final fun <get-i> (): kotlin.Int declared in <root>.Counter' type=kotlin.Int origin=GET_PROPERTY
CALL 'public final fun <get-i> (): kotlin.Int declared in <root>.Counter' type=kotlin.Int origin=POSTFIX_INCR
$this: GET_VAR 'val tmp_2: <root>.Counter declared in <root>.CounterIterator.next' type=<root>.Counter origin=null
CALL 'public final fun <set-i> (<set-?>: kotlin.Int): kotlin.Unit declared in <root>.Counter' type=kotlin.Unit origin=EQ
CALL 'public final fun <set-i> (<set-?>: kotlin.Int): kotlin.Unit declared in <root>.Counter' type=kotlin.Unit origin=POSTFIX_INCR
$this: GET_VAR 'val tmp_2: <root>.Counter declared in <root>.CounterIterator.next' type=<root>.Counter origin=null
<set-?>: CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
<set-?>: CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=POSTFIX_INCR
$this: GET_VAR 'val tmp_3: kotlin.Int declared in <root>.CounterIterator.next' type=kotlin.Int origin=null
GET_VAR 'val tmp_3: kotlin.Int declared in <root>.CounterIterator.next' type=kotlin.Int origin=null
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
@@ -186,20 +186,20 @@ FILE fqName:<root> fileName:/unaryOperators.kt
$receiver: VALUE_PARAMETER name:$this$with type:kotlin.Int
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
BLOCK type=<root>.Result origin=null
BLOCK type=<root>.Result origin=POSTFIX_INCR
VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:<root>.Result [val]
GET_VAR 'var result: <root>.Result declared in <root>.box' type=<root>.Result origin=null
SET_VAR 'var result: <root>.Result declared in <root>.box' type=kotlin.Unit origin=EQ
CALL 'public final fun inc ($context_receiver_0: kotlin.Int): <root>.Result declared in <root>' type=<root>.Result origin=null
GET_VAR 'var result: <root>.Result declared in <root>.box' type=<root>.Result origin=POSTFIX_INCR
SET_VAR 'var result: <root>.Result declared in <root>.box' type=kotlin.Unit origin=POSTFIX_INCR
CALL 'public final fun inc ($context_receiver_0: kotlin.Int): <root>.Result declared in <root>' type=<root>.Result origin=POSTFIX_INCR
$receiver: GET_VAR 'val tmp_1: <root>.Result declared in <root>.box.<anonymous>' type=<root>.Result origin=null
$context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in <root>.box.<anonymous>' type=kotlin.Int origin=null
GET_VAR 'val tmp_1: <root>.Result declared in <root>.box.<anonymous>' type=<root>.Result origin=null
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
BLOCK type=<root>.Result origin=null
BLOCK type=<root>.Result origin=POSTFIX_INCR
VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:<root>.Result [val]
GET_VAR 'var result: <root>.Result declared in <root>.box' type=<root>.Result origin=null
SET_VAR 'var result: <root>.Result declared in <root>.box' type=kotlin.Unit origin=EQ
CALL 'public final fun inc ($context_receiver_0: kotlin.Int): <root>.Result declared in <root>' type=<root>.Result origin=null
GET_VAR 'var result: <root>.Result declared in <root>.box' type=<root>.Result origin=POSTFIX_INCR
SET_VAR 'var result: <root>.Result declared in <root>.box' type=kotlin.Unit origin=POSTFIX_INCR
CALL 'public final fun inc ($context_receiver_0: kotlin.Int): <root>.Result declared in <root>' type=<root>.Result origin=POSTFIX_INCR
$receiver: GET_VAR 'val tmp_2: <root>.Result declared in <root>.box.<anonymous>' type=<root>.Result origin=null
$context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in <root>.box.<anonymous>' type=kotlin.Int origin=null
GET_VAR 'val tmp_2: <root>.Result declared in <root>.box.<anonymous>' type=<root>.Result origin=null
@@ -212,11 +212,11 @@ FILE fqName:<root> fileName:/unaryOperators.kt
$receiver: GET_VAR 'var result: <root>.Result declared in <root>.box' type=<root>.Result origin=null
$context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in <root>.box.<anonymous>' type=kotlin.Int origin=null
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): <root>.Result declared in <root>.box'
BLOCK type=<root>.Result origin=null
BLOCK type=<root>.Result origin=POSTFIX_DECR
VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:<root>.Result [val]
GET_VAR 'var result: <root>.Result declared in <root>.box' type=<root>.Result origin=null
SET_VAR 'var result: <root>.Result declared in <root>.box' type=kotlin.Unit origin=EQ
CALL 'public final fun dec ($context_receiver_0: kotlin.Int): <root>.Result declared in <root>' type=<root>.Result origin=null
GET_VAR 'var result: <root>.Result declared in <root>.box' type=<root>.Result origin=POSTFIX_DECR
SET_VAR 'var result: <root>.Result declared in <root>.box' type=kotlin.Unit origin=POSTFIX_DECR
CALL 'public final fun dec ($context_receiver_0: kotlin.Int): <root>.Result declared in <root>' type=<root>.Result origin=POSTFIX_DECR
$receiver: GET_VAR 'val tmp_3: <root>.Result declared in <root>.box.<anonymous>' type=<root>.Result origin=null
$context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in <root>.box.<anonymous>' type=kotlin.Int origin=null
GET_VAR 'val tmp_3: <root>.Result declared in <root>.box.<anonymous>' type=<root>.Result origin=null
@@ -53,7 +53,7 @@ FILE fqName:<root> fileName:/localDelegatedProperties.kt
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int [val]
CALL 'local final fun <get-x> (): kotlin.Int declared in <root>.test2' type=kotlin.Int origin=GET_LOCAL_PROPERTY
CALL 'local final fun <set-x> (<set-?>: kotlin.Int): kotlin.Unit declared in <root>.test2' type=kotlin.Unit origin=POSTFIX_INCR
<set-?>: CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
<set-?>: CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=POSTFIX_INCR
$this: GET_VAR 'val tmp_0: kotlin.Int declared in <root>.test2' type=kotlin.Int origin=null
GET_VAR 'val tmp_0: kotlin.Int declared in <root>.test2' type=kotlin.Int origin=null
CALL 'local final fun <set-x> (<set-?>: kotlin.Int): kotlin.Unit declared in <root>.test2' type=kotlin.Unit origin=PLUSEQ