[FIR] Fix building fir for += with complex rhs

Also fix choosing candidate for assignment operator call
This commit is contained in:
Dmitriy Novozhilov
2019-11-07 12:20:00 +03:00
parent cadc2dfe4d
commit b5210e6a9b
15 changed files with 132 additions and 73 deletions
@@ -40,15 +40,13 @@ FILE fqName:<root> fileName:/augmentedAssignmentWithExpression.kt
x: CONST Int type=kotlin.Int value=1
FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:<root>.Host [val]
CALL 'public final fun foo (): <root>.Host declared in <root>' type=<root>.Host origin=null
SET_VAR 'val tmp_0: <root>.Host [val] declared in <root>.test3' type=<root>.Host origin=null
CONST Int type=<root>.Host value=1
CALL 'public final fun plusAssign (x: kotlin.Int): kotlin.Unit declared in <root>.Host' type=kotlin.Unit origin=null
$this: CALL 'public final fun foo (): <root>.Host declared in <root>' type=<root>.Host origin=null
x: CONST Int type=kotlin.Int value=1
FUN name:test4 visibility:public modality:FINAL <> (a:kotlin.Function0<<root>.Host>) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<<root>.Host>
BLOCK_BODY
VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:<root>.Host [val]
CALL 'public abstract fun invoke (): <root>.Host declared in kotlin.Function0' type=<root>.Host origin=null
CALL 'public final fun plusAssign (x: kotlin.Int): kotlin.Unit declared in <root>.Host' type=kotlin.Unit origin=null
$this: CALL 'public abstract fun invoke (): <root>.Host declared in kotlin.Function0' type=<root>.Host origin=null
$this: GET_VAR 'a: kotlin.Function0<<root>.Host> declared in <root>.test4' type=kotlin.Function0<<root>.Host> origin=null
SET_VAR 'val tmp_1: <root>.Host [val] declared in <root>.test4' type=<root>.Host origin=null
CONST Int type=<root>.Host value=1
x: CONST Int type=kotlin.Int value=1
@@ -10,4 +10,4 @@ FILE fqName:<root> fileName:/javaSyntheticPropertyAccess.kt
$this: GET_VAR 'j: <root>.J declared in <root>.test' type=<root>.J origin=null
ERROR_CALL 'Unresolved reference: R|/J.foo|' type=IrErrorType
GET_VAR 'val tmp_0: kotlin.Int [val] declared in <root>.test' type=kotlin.Int origin=null
ERROR_CALL 'Unresolved reference: R|/J.foo|' type=IrErrorType
ERROR_CALL 'Unresolved reference: <Variable expected>#' type=IrErrorType
+31 -30
View File
@@ -28,61 +28,58 @@ FILE fqName:<root> fileName:/kt30020.kt
$receiver: CALL 'public abstract fun <get-xs> (): kotlin.collections.MutableList<kotlin.Any> declared in <root>.X' type=kotlin.collections.MutableList<kotlin.Any> origin=null
$this: GET_VAR 'x: <root>.X declared in <root>.test' type=<root>.X origin=null
element: CONST Int type=kotlin.Int value=1
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.collections.MutableList<kotlin.Any> [val]
CALL 'public abstract fun f (): kotlin.collections.MutableList<kotlin.Any> declared in <root>.X' type=kotlin.collections.MutableList<kotlin.Any> origin=null
CALL 'public final fun plusAssign (element: T of <uninitialized parent>): kotlin.Unit [inline] declared in kotlin.collections' type=kotlin.Unit origin=null
$receiver: CALL 'public abstract fun f (): kotlin.collections.MutableList<kotlin.Any> declared in <root>.X' type=kotlin.collections.MutableList<kotlin.Any> origin=null
$this: GET_VAR 'x: <root>.X declared in <root>.test' type=<root>.X origin=null
SET_VAR 'val tmp_0: kotlin.collections.MutableList<kotlin.Any> [val] declared in <root>.test' type=kotlin.collections.MutableList<kotlin.Any> origin=null
CONST Int type=kotlin.collections.MutableList<kotlin.Any> value=2
VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.collections.MutableList<kotlin.Int> [val]
TYPE_OP type=kotlin.collections.MutableList<kotlin.Int> origin=CAST typeOperand=kotlin.collections.MutableList<kotlin.Int>
CALL 'public abstract fun <get-xs> (): kotlin.collections.MutableList<kotlin.Any> declared in <root>.X' type=kotlin.collections.MutableList<kotlin.Any> origin=null
element: CONST Int type=kotlin.Int value=2
CALL 'public final fun plusAssign (element: T of <uninitialized parent>): kotlin.Unit [inline] declared in kotlin.collections' type=kotlin.Unit origin=null
$receiver: TYPE_OP type=kotlin.collections.MutableList<kotlin.Int> origin=CAST typeOperand=kotlin.collections.MutableList<kotlin.Int>
CALL 'public abstract fun <get-xs> (): kotlin.collections.MutableList<kotlin.Any> declared in <root>.X' type=kotlin.collections.MutableList<kotlin.Int> origin=null
$this: GET_VAR 'x: <root>.X declared in <root>.test' type=<root>.X origin=null
SET_VAR 'val tmp_1: kotlin.collections.MutableList<kotlin.Int> [val] declared in <root>.test' type=kotlin.collections.MutableList<kotlin.Int> origin=null
CONST Int type=kotlin.collections.MutableList<kotlin.Int> value=3
VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.collections.MutableList<kotlin.Int> [val]
TYPE_OP type=kotlin.collections.MutableList<kotlin.Int> origin=CAST typeOperand=kotlin.collections.MutableList<kotlin.Int>
element: CONST Int type=kotlin.Int value=3
CALL 'public final fun plusAssign (element: T of <uninitialized parent>): kotlin.Unit [inline] declared in kotlin.collections' type=kotlin.Unit origin=null
$receiver: TYPE_OP type=kotlin.collections.MutableList<kotlin.Int> origin=CAST typeOperand=kotlin.collections.MutableList<kotlin.Int>
CALL 'public abstract fun f (): kotlin.collections.MutableList<kotlin.Any> declared in <root>.X' type=kotlin.collections.MutableList<kotlin.Any> origin=null
$this: GET_VAR 'x: <root>.X declared in <root>.test' type=<root>.X origin=null
SET_VAR 'val tmp_2: kotlin.collections.MutableList<kotlin.Int> [val] declared in <root>.test' type=kotlin.collections.MutableList<kotlin.Int> origin=null
CONST Int type=kotlin.collections.MutableList<kotlin.Int> value=4
VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.collections.MutableList<kotlin.Int> [val]
BLOCK type=kotlin.collections.MutableList<kotlin.Int> origin=EXCLEXCL
VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:kotlin.collections.MutableList<kotlin.Int> [val]
element: CONST Int type=kotlin.Int value=4
CALL 'public final fun plusAssign (element: T of <uninitialized parent>): kotlin.Unit [inline] declared in kotlin.collections' type=kotlin.Unit origin=null
$receiver: BLOCK type=kotlin.collections.MutableList<kotlin.Int> origin=EXCLEXCL
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.collections.MutableList<kotlin.Int> [val]
CALL 'public abstract fun <get-xs> (): kotlin.collections.MutableList<kotlin.Any> declared in <root>.X' type=kotlin.collections.MutableList<kotlin.Int> origin=null
$this: GET_VAR 'nx: <root>.X? declared in <root>.test' type=<root>.X? origin=null
WHEN type=kotlin.collections.MutableList<kotlin.Int> origin=EXCLEXCL
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_4: kotlin.collections.MutableList<kotlin.Int> [val] declared in <root>.test' type=kotlin.collections.MutableList<kotlin.Int> origin=null
arg0: GET_VAR 'val tmp_0: kotlin.collections.MutableList<kotlin.Int> [val] declared in <root>.test' type=kotlin.collections.MutableList<kotlin.Int> origin=null
arg1: CONST Null type=kotlin.Nothing? value=null
then: THROW type=kotlin.Nothing
CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.KotlinNullPointerException' type=kotlin.KotlinNullPointerException origin=null
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_4: kotlin.collections.MutableList<kotlin.Int> [val] declared in <root>.test' type=kotlin.collections.MutableList<kotlin.Int> origin=null
SET_VAR 'val tmp_3: kotlin.collections.MutableList<kotlin.Int> [val] declared in <root>.test' type=kotlin.collections.MutableList<kotlin.Int> origin=null
CONST Int type=kotlin.collections.MutableList<kotlin.Int> value=5
VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:kotlin.collections.MutableList<kotlin.Int> [val]
BLOCK type=kotlin.collections.MutableList<kotlin.Int> origin=EXCLEXCL
VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:kotlin.collections.MutableList<kotlin.Any>? [val]
then: GET_VAR 'val tmp_0: kotlin.collections.MutableList<kotlin.Int> [val] declared in <root>.test' type=kotlin.collections.MutableList<kotlin.Int> origin=null
element: CONST Int type=kotlin.Int value=5
CALL 'public final fun plusAssign (element: T of <uninitialized parent>): kotlin.Unit [inline] declared in kotlin.collections' type=kotlin.Unit origin=null
$receiver: BLOCK type=kotlin.collections.MutableList<kotlin.Int> origin=EXCLEXCL
VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.collections.MutableList<kotlin.Any>? [val]
CALL 'public abstract fun f (): kotlin.collections.MutableList<kotlin.Any> declared in <root>.X' type=kotlin.collections.MutableList<kotlin.Any>? origin=null
$this: GET_VAR 'nx: <root>.X? declared in <root>.test' type=<root>.X origin=null
WHEN type=kotlin.collections.MutableList<kotlin.Int> origin=EXCLEXCL
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_6: kotlin.collections.MutableList<kotlin.Any>? [val] declared in <root>.test' type=kotlin.collections.MutableList<kotlin.Any>? origin=null
arg0: GET_VAR 'val tmp_1: kotlin.collections.MutableList<kotlin.Any>? [val] declared in <root>.test' type=kotlin.collections.MutableList<kotlin.Any>? origin=null
arg1: CONST Null type=kotlin.Nothing? value=null
then: THROW type=kotlin.Nothing
CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.KotlinNullPointerException' type=kotlin.KotlinNullPointerException origin=null
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_6: kotlin.collections.MutableList<kotlin.Any>? [val] declared in <root>.test' type=kotlin.collections.MutableList<kotlin.Int> origin=null
SET_VAR 'val tmp_5: kotlin.collections.MutableList<kotlin.Int> [val] declared in <root>.test' type=kotlin.collections.MutableList<kotlin.Int> origin=null
CONST Int type=kotlin.collections.MutableList<kotlin.Int> value=6
then: GET_VAR 'val tmp_1: kotlin.collections.MutableList<kotlin.Any>? [val] declared in <root>.test' type=kotlin.collections.MutableList<kotlin.Int> origin=null
element: CONST Int type=kotlin.Int value=6
FUN name:testExtensionReceiver visibility:public modality:FINAL <> ($receiver:kotlin.collections.MutableList<kotlin.Any>) returnType:kotlin.Unit
$receiver: VALUE_PARAMETER name:<this> type:kotlin.collections.MutableList<kotlin.Any>
BLOCK_BODY
ERROR_EXPR 'Operator overload ambiguity. Compatible candidates: [kotlin/collections/plus, kotlin/collections/plusAssign]' type=IrErrorType
CALL 'public final fun plusAssign (element: T of <uninitialized parent>): kotlin.Unit [inline] declared in kotlin.collections' type=kotlin.Unit origin=null
$receiver: GET_VAR '<this>: kotlin.collections.MutableList<kotlin.Any> declared in <root>.testExtensionReceiver' type=kotlin.collections.MutableList<kotlin.Any> origin=null
element: CONST Int type=kotlin.Int value=100
CLASS CLASS name:AML modality:ABSTRACT visibility:public superTypes:[kotlin.collections.MutableList<kotlin.Int>]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.AML
CONSTRUCTOR visibility:public <> () returnType:<root>.AML [primary]
@@ -92,7 +89,9 @@ FILE fqName:<root> fileName:/kt30020.kt
FUN name:testExplicitThis visibility:public modality:FINAL <> ($this:<root>.AML) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.AML
BLOCK_BODY
ERROR_EXPR 'Operator overload ambiguity. Compatible candidates: [kotlin/collections/plus, kotlin/collections/plusAssign]' type=IrErrorType
CALL 'public final fun plusAssign (element: T of <uninitialized parent>): kotlin.Unit [inline] declared in kotlin.collections' type=kotlin.Unit origin=null
$receiver: GET_VAR '<this>: <root>.AML declared in <root>.AML' type=<root>.AML origin=null
element: CONST Int type=kotlin.Int value=200
CLASS CLASS name:Inner modality:FINAL visibility:public [inner] superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.AML.Inner
CONSTRUCTOR visibility:public <> () returnType:<root>.AML.Inner [primary]
@@ -102,7 +101,9 @@ FILE fqName:<root> fileName:/kt30020.kt
FUN name:testOuterThis visibility:public modality:FINAL <> ($this:<root>.AML.Inner) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.AML.Inner
BLOCK_BODY
ERROR_EXPR 'Operator overload ambiguity. Compatible candidates: [kotlin/collections/plus, kotlin/collections/plusAssign]' type=IrErrorType
CALL 'public final fun plusAssign (element: T of <uninitialized parent>): kotlin.Unit [inline] declared in kotlin.collections' type=kotlin.Unit origin=null
$receiver: GET_VAR '<this>: <root>.AML declared in <root>.AML' type=<root>.AML origin=null
element: CONST Int type=kotlin.Int value=300
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any