[FIR] Extract LHS receiver of assignment operator statements

#KT-53490 Fixed
This commit is contained in:
Brian Norman
2023-06-30 17:13:05 +03:00
committed by Space Team
parent 14276642d4
commit 10ed26991d
45 changed files with 1894 additions and 124 deletions
@@ -21,9 +21,12 @@ FILE fqName:<root> fileName:/javaSyntheticGenericPropertyAccess.kt
x: CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
$this: GET_VAR 'val tmp_1: kotlin.Int declared in <root>.test' type=kotlin.Int origin=null
GET_VAR 'val tmp_1: kotlin.Int declared in <root>.test' type=kotlin.Int origin=null
CALL 'public open fun setFoo (x: kotlin.Int): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=EQ
$this: GET_VAR 'j: <root>.J<F of <root>.test> declared in <root>.test' type=<root>.J<F of <root>.test> origin=null
x: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
$this: CALL 'public open fun getFoo (): kotlin.Int declared in <root>.J' type=kotlin.Int origin=GET_PROPERTY
$this: GET_VAR 'j: <root>.J<F of <root>.test> declared in <root>.test' type=<root>.J<F of <root>.test> origin=null
other: CONST Int type=kotlin.Int value=1
BLOCK type=kotlin.Unit origin=null
VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:<root>.J<F of <root>.test> [val]
GET_VAR 'j: <root>.J<F of <root>.test> declared in <root>.test' type=<root>.J<F of <root>.test> origin=null
CALL 'public open fun setFoo (x: kotlin.Int): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=EQ
$this: GET_VAR 'val tmp_2: <root>.J<F of <root>.test> declared in <root>.test' type=<root>.J<F of <root>.test> origin=null
x: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
$this: CALL 'public open fun getFoo (): kotlin.Int declared in <root>.J' type=kotlin.Int origin=GET_PROPERTY
$this: GET_VAR 'val tmp_2: <root>.J<F of <root>.test> declared in <root>.test' type=<root>.J<F of <root>.test> origin=null
other: CONST Int type=kotlin.Int value=1
@@ -7,5 +7,8 @@ fun <F : Any?> test(j: J<F>) {
<receiver>.setFoo(x = <unary>.inc())
<unary>
} /*~> Unit */
j.setFoo(x = j.getFoo().plus(other = 1))
{ // BLOCK
val <receiver>: J<F> = j
<receiver>.setFoo(x = <receiver>.getFoo().plus(other = 1))
}
}
@@ -20,9 +20,12 @@ FILE fqName:<root> fileName:/javaSyntheticPropertyAccess.kt
x: CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
$this: GET_VAR 'val tmp_1: kotlin.Int declared in <root>.test' type=kotlin.Int origin=null
GET_VAR 'val tmp_1: kotlin.Int declared in <root>.test' type=kotlin.Int origin=null
CALL 'public open fun setFoo (x: kotlin.Int): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=EQ
$this: GET_VAR 'j: <root>.J declared in <root>.test' type=<root>.J origin=null
x: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
$this: CALL 'public open fun getFoo (): kotlin.Int declared in <root>.J' type=kotlin.Int origin=GET_PROPERTY
$this: GET_VAR 'j: <root>.J declared in <root>.test' type=<root>.J origin=null
other: CONST Int type=kotlin.Int value=1
BLOCK type=kotlin.Unit origin=null
VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:<root>.J [val]
GET_VAR 'j: <root>.J declared in <root>.test' type=<root>.J origin=null
CALL 'public open fun setFoo (x: kotlin.Int): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=EQ
$this: GET_VAR 'val tmp_2: <root>.J declared in <root>.test' type=<root>.J origin=null
x: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
$this: CALL 'public open fun getFoo (): kotlin.Int declared in <root>.J' type=kotlin.Int origin=GET_PROPERTY
$this: GET_VAR 'val tmp_2: <root>.J declared in <root>.test' type=<root>.J origin=null
other: CONST Int type=kotlin.Int value=1
@@ -7,5 +7,8 @@ fun test(j: J) {
<receiver>.setFoo(x = <unary>.inc())
<unary>
} /*~> Unit */
j.setFoo(x = j.getFoo().plus(other = 1))
{ // BLOCK
val <receiver>: J = j
<receiver>.setFoo(x = <receiver>.getFoo().plus(other = 1))
}
}
@@ -74,42 +74,44 @@ FILE fqName:test fileName:/safeCallWithIncrementDecrement.kt
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: BLOCK type=kotlin.Int origin=null
VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Int [val]
VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:test.C [val]
GET_VAR 'val tmp_1: test.C? declared in test.testProperty' type=test.C? origin=null
VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val]
CALL 'public final fun <get-p> (): kotlin.Int declared in test' type=kotlin.Int origin=GET_PROPERTY
$receiver: GET_VAR 'val tmp_1: test.C? declared in test.testProperty' type=test.C? origin=null
$receiver: GET_VAR 'val tmp_2: test.C declared in test.testProperty' type=test.C origin=null
CALL 'public final fun <set-p> (value: kotlin.Int): kotlin.Unit declared in test' type=kotlin.Unit origin=EQ
$receiver: GET_VAR 'val tmp_1: test.C? declared in test.testProperty' type=test.C? origin=null
$receiver: GET_VAR 'val tmp_2: test.C declared in test.testProperty' type=test.C origin=null
value: CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
$this: GET_VAR 'val tmp_2: kotlin.Int declared in test.testProperty' type=kotlin.Int origin=null
GET_VAR 'val tmp_2: kotlin.Int declared in test.testProperty' type=kotlin.Int origin=null
$this: GET_VAR 'val tmp_3: kotlin.Int declared in test.testProperty' type=kotlin.Int origin=null
GET_VAR 'val tmp_3: kotlin.Int declared in test.testProperty' type=kotlin.Int origin=null
FUN name:testArrayAccess visibility:public modality:FINAL <> (nc:test.C?) returnType:kotlin.Unit
VALUE_PARAMETER name:nc index:0 type:test.C?
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
BLOCK type=kotlin.Int? origin=SAFE_CALL
VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:test.C? [val]
VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:test.C? [val]
GET_VAR 'nc: test.C? declared in test.testArrayAccess' type=test.C? origin=null
WHEN type=kotlin.Int? origin=null
BRANCH
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
arg0: GET_VAR 'val tmp_3: test.C? declared in test.testArrayAccess' type=test.C? origin=null
arg0: GET_VAR 'val tmp_4: test.C? declared in test.testArrayAccess' type=test.C? origin=null
arg1: CONST Null type=kotlin.Nothing? value=null
then: CONST Null type=kotlin.Nothing? value=null
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: BLOCK type=kotlin.Int origin=null
VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:kotlin.Int [val]
CALL 'public final fun <get-p> (): kotlin.Int declared in test' type=kotlin.Int origin=GET_PROPERTY
$receiver: GET_VAR 'val tmp_3: test.C? declared in test.testArrayAccess' type=test.C? origin=null
VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:kotlin.Int [val]
CONST Int type=kotlin.Int value=0
CALL 'public final fun <get-p> (): kotlin.Int declared in test' type=kotlin.Int origin=GET_PROPERTY
$receiver: GET_VAR 'val tmp_4: test.C? declared in test.testArrayAccess' type=test.C? origin=null
VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:kotlin.Int [val]
CONST Int type=kotlin.Int value=0
VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:kotlin.Int [val]
CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in test' type=kotlin.Int origin=null
$receiver: GET_VAR 'val tmp_4: kotlin.Int declared in test.testArrayAccess' type=kotlin.Int origin=null
index: GET_VAR 'val tmp_5: kotlin.Int declared in test.testArrayAccess' type=kotlin.Int origin=null
$receiver: GET_VAR 'val tmp_5: kotlin.Int declared in test.testArrayAccess' type=kotlin.Int origin=null
index: GET_VAR 'val tmp_6: kotlin.Int declared in test.testArrayAccess' type=kotlin.Int origin=null
CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in test' type=kotlin.Unit origin=null
$receiver: GET_VAR 'val tmp_4: kotlin.Int declared in test.testArrayAccess' type=kotlin.Int origin=null
index: GET_VAR 'val tmp_5: kotlin.Int declared in test.testArrayAccess' type=kotlin.Int origin=null
$receiver: GET_VAR 'val tmp_5: kotlin.Int declared in test.testArrayAccess' type=kotlin.Int origin=null
index: GET_VAR 'val tmp_6: kotlin.Int declared in test.testArrayAccess' type=kotlin.Int origin=null
value: CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
$this: GET_VAR 'val tmp_6: kotlin.Int declared in test.testArrayAccess' type=kotlin.Int origin=null
GET_VAR 'val tmp_6: kotlin.Int declared in test.testArrayAccess' type=kotlin.Int origin=null
$this: GET_VAR 'val tmp_7: kotlin.Int declared in test.testArrayAccess' type=kotlin.Int origin=null
GET_VAR 'val tmp_7: kotlin.Int declared in test.testArrayAccess' type=kotlin.Int origin=null
@@ -39,8 +39,9 @@ fun testProperty(nc: C?) {
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())
val <receiver>: C = tmp1_safe_receiver
val <unary>: Int = <receiver>.<get-p>()
<receiver>.<set-p>(value = <unary>.inc())
<unary>
}
}