diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt index 37c2c5f9bdb..ef803c60fbc 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt @@ -609,7 +609,9 @@ class Fir2IrDeclarationStorage( base.startOffset, base.endOffset, IrDeclarationOrigin.IR_TEMPORARY_VARIABLE, Name.identifier(getNameForTemporary(nameHint)), base.type, isVar = false, isConst = false, isLateinit = false - ) + ).apply { + initializer = base + } } fun getIrClassSymbol(firClassSymbol: FirClassSymbol): IrClassSymbol { diff --git a/compiler/testData/ir/irText/expressions/floatingPointComparisons/whenByFloatingPoint.fir.txt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/whenByFloatingPoint.fir.txt index 1b8f933ec20..004a2c17978 100644 --- a/compiler/testData/ir/irText/expressions/floatingPointComparisons/whenByFloatingPoint.fir.txt +++ b/compiler/testData/ir/irText/expressions/floatingPointComparisons/whenByFloatingPoint.fir.txt @@ -5,6 +5,7 @@ FILE fqName: fileName:/whenByFloatingPoint.kt RETURN type=kotlin.Nothing from='public final fun testSimple (x: kotlin.Double): kotlin.Int declared in ' BLOCK type=kotlin.Int origin=WHEN VAR IR_TEMPORARY_VARIABLE name:tmp0_subject type:kotlin.Double [val] + GET_VAR 'x: kotlin.Double declared in .testSimple' type=kotlin.Double origin=null WHEN type=kotlin.Int origin=WHEN 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 @@ -27,6 +28,7 @@ FILE fqName: fileName:/whenByFloatingPoint.kt RETURN type=kotlin.Nothing from='public final fun testSmartCastInWhenSubject (x: kotlin.Any): kotlin.Int declared in ' BLOCK type=kotlin.Int origin=WHEN VAR IR_TEMPORARY_VARIABLE name:tmp1_subject type:kotlin.Double [val] + GET_VAR 'x: kotlin.Any declared in .testSmartCastInWhenSubject' type=kotlin.Double origin=null WHEN type=kotlin.Int origin=WHEN 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 @@ -50,6 +52,7 @@ FILE fqName: fileName:/whenByFloatingPoint.kt RETURN type=kotlin.Nothing from='public final fun testSmartCastInWhenCondition (x: kotlin.Double, y: kotlin.Any): kotlin.Int declared in ' BLOCK type=kotlin.Int origin=WHEN VAR IR_TEMPORARY_VARIABLE name:tmp2_subject type:kotlin.Double [val] + GET_VAR 'x: kotlin.Double declared in .testSmartCastInWhenCondition' type=kotlin.Double origin=null WHEN type=kotlin.Int origin=WHEN 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 @@ -65,6 +68,7 @@ FILE fqName: fileName:/whenByFloatingPoint.kt RETURN type=kotlin.Nothing from='public final fun testSmartCastInWhenConditionInBranch (x: kotlin.Any): kotlin.Int declared in ' BLOCK type=kotlin.Int origin=WHEN VAR IR_TEMPORARY_VARIABLE name:tmp3_subject type:kotlin.Any [val] + GET_VAR 'x: kotlin.Any declared in .testSmartCastInWhenConditionInBranch' type=kotlin.Any origin=null WHEN type=kotlin.Int origin=WHEN BRANCH if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=kotlin.Double @@ -100,6 +104,7 @@ FILE fqName: fileName:/whenByFloatingPoint.kt RETURN type=kotlin.Nothing from='public final fun testSmartCastToDifferentTypes (x: kotlin.Any, y: kotlin.Any): kotlin.Int declared in ' BLOCK type=kotlin.Int origin=WHEN VAR IR_TEMPORARY_VARIABLE name:tmp4_subject type:kotlin.Double [val] + GET_VAR 'x: kotlin.Any declared in .testSmartCastToDifferentTypes' type=kotlin.Double origin=null WHEN type=kotlin.Int origin=WHEN 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 @@ -120,6 +125,7 @@ FILE fqName: fileName:/whenByFloatingPoint.kt RETURN type=kotlin.Nothing from='public final fun testWithPrematureExitInConditionSubexpression (x: kotlin.Any): kotlin.Int declared in ' BLOCK type=kotlin.Int origin=WHEN VAR IR_TEMPORARY_VARIABLE name:tmp5_subject type:kotlin.Any [val] + GET_VAR 'x: kotlin.Any declared in .testWithPrematureExitInConditionSubexpression' type=kotlin.Any origin=null WHEN type=kotlin.Int origin=WHEN 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 diff --git a/compiler/testData/ir/irText/expressions/when.fir.txt b/compiler/testData/ir/irText/expressions/when.fir.txt index 04fc292b6f1..ff73a0708cf 100644 --- a/compiler/testData/ir/irText/expressions/when.fir.txt +++ b/compiler/testData/ir/irText/expressions/when.fir.txt @@ -24,6 +24,7 @@ FILE fqName: fileName:/when.kt RETURN type=kotlin.Nothing from='public final fun testWithSubject (x: kotlin.Any?): kotlin.String declared in ' BLOCK type=kotlin.String origin=WHEN VAR IR_TEMPORARY_VARIABLE name:tmp0_subject type:kotlin.Any? [val] + GET_VAR 'x: kotlin.Any? declared in .testWithSubject' type=kotlin.Any? origin=null WHEN type=kotlin.String origin=WHEN 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 @@ -88,6 +89,7 @@ FILE fqName: fileName:/when.kt RETURN type=kotlin.Nothing from='public final fun testComma (x: kotlin.Int): kotlin.String declared in ' BLOCK type=kotlin.String origin=WHEN VAR IR_TEMPORARY_VARIABLE name:tmp1_subject type:kotlin.Int [val] + GET_VAR 'x: kotlin.Int declared in .testComma' type=kotlin.Int origin=null WHEN type=kotlin.String origin=WHEN BRANCH if: WHEN type=kotlin.Boolean origin=OROR diff --git a/compiler/testData/ir/irText/expressions/whenCoercedToUnit.fir.txt b/compiler/testData/ir/irText/expressions/whenCoercedToUnit.fir.txt index da87de4dc9e..38130e88eb3 100644 --- a/compiler/testData/ir/irText/expressions/whenCoercedToUnit.fir.txt +++ b/compiler/testData/ir/irText/expressions/whenCoercedToUnit.fir.txt @@ -4,6 +4,7 @@ FILE fqName: fileName:/whenCoercedToUnit.kt BLOCK_BODY BLOCK type=kotlin.Unit origin=WHEN VAR IR_TEMPORARY_VARIABLE name:tmp0_subject type:kotlin.Int [val] + GET_VAR 'x: kotlin.Int declared in .foo' type=kotlin.Int origin=null WHEN type=kotlin.Unit origin=WHEN 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 diff --git a/compiler/testData/ir/irText/expressions/whenReturn.fir.txt b/compiler/testData/ir/irText/expressions/whenReturn.fir.txt index bcb2357efa5..58a390e3179 100644 --- a/compiler/testData/ir/irText/expressions/whenReturn.fir.txt +++ b/compiler/testData/ir/irText/expressions/whenReturn.fir.txt @@ -4,6 +4,7 @@ FILE fqName: fileName:/whenReturn.kt BLOCK_BODY BLOCK type=kotlin.String origin=WHEN VAR IR_TEMPORARY_VARIABLE name:tmp0_subject type:kotlin.String [val] + GET_VAR 'grade: kotlin.String declared in .toString' type=kotlin.String origin=null WHEN type=kotlin.String origin=WHEN 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 diff --git a/compiler/testData/ir/irText/expressions/whenUnusedExpression.fir.txt b/compiler/testData/ir/irText/expressions/whenUnusedExpression.fir.txt index fbcf40223b8..9479e156e51 100644 --- a/compiler/testData/ir/irText/expressions/whenUnusedExpression.fir.txt +++ b/compiler/testData/ir/irText/expressions/whenUnusedExpression.fir.txt @@ -8,6 +8,7 @@ FILE fqName: fileName:/whenUnusedExpression.kt if: GET_VAR 'b: kotlin.Boolean declared in .test' type=kotlin.Boolean origin=null then: BLOCK type=kotlin.Int? origin=WHEN VAR IR_TEMPORARY_VARIABLE name:tmp0_subject type:kotlin.Int [val] + GET_VAR 'i: kotlin.Int declared in .test' type=kotlin.Int origin=null WHEN type=kotlin.Int? origin=WHEN 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 diff --git a/compiler/testData/ir/irText/regressions/kt24114.fir.txt b/compiler/testData/ir/irText/regressions/kt24114.fir.txt index dc4e9d4ef00..b0f3ebce7f4 100644 --- a/compiler/testData/ir/irText/regressions/kt24114.fir.txt +++ b/compiler/testData/ir/irText/regressions/kt24114.fir.txt @@ -13,6 +13,7 @@ FILE fqName: fileName:/kt24114.kt condition: CONST Boolean type=kotlin.Boolean value=true body: BLOCK type=kotlin.Unit origin=WHEN VAR IR_TEMPORARY_VARIABLE name:tmp0_subject type:kotlin.Int [val] + CALL 'public final fun one (): kotlin.Int declared in ' type=kotlin.Int origin=null WHEN type=kotlin.Unit origin=WHEN 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 @@ -20,6 +21,7 @@ FILE fqName: fileName:/kt24114.kt arg1: CONST Int type=kotlin.Int value=1 then: BLOCK type=kotlin.Unit origin=WHEN VAR IR_TEMPORARY_VARIABLE name:tmp1_subject type:kotlin.Int [val] + CALL 'public final fun two (): kotlin.Int declared in ' type=kotlin.Int origin=null WHEN type=kotlin.Unit origin=WHEN 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 @@ -37,6 +39,7 @@ FILE fqName: fileName:/kt24114.kt condition: CONST Boolean type=kotlin.Boolean value=true body: BLOCK type=kotlin.Unit origin=WHEN VAR IR_TEMPORARY_VARIABLE name:tmp2_subject type:kotlin.Int [val] + CALL 'public final fun one (): kotlin.Int declared in ' type=kotlin.Int origin=null WHEN type=kotlin.Unit origin=WHEN 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 @@ -44,6 +47,7 @@ FILE fqName: fileName:/kt24114.kt arg1: CONST Int type=kotlin.Int value=1 then: BLOCK type=kotlin.Unit origin=WHEN VAR IR_TEMPORARY_VARIABLE name:tmp3_subject type:kotlin.Int [val] + CALL 'public final fun two (): kotlin.Int declared in ' type=kotlin.Int origin=null WHEN type=kotlin.Unit origin=WHEN 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