Fir2Ir: Set initializers for temporary variables

This commit is contained in:
Steven Schäfer
2019-10-25 11:57:52 +02:00
committed by Dmitriy Novozhilov
parent cf61957e3c
commit 210c354ae5
7 changed files with 18 additions and 1 deletions
@@ -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 {
@@ -5,6 +5,7 @@ FILE fqName:<root> fileName:/whenByFloatingPoint.kt
RETURN type=kotlin.Nothing from='public final fun testSimple (x: kotlin.Double): kotlin.Int declared in <root>'
BLOCK type=kotlin.Int origin=WHEN
VAR IR_TEMPORARY_VARIABLE name:tmp0_subject type:kotlin.Double [val]
GET_VAR 'x: kotlin.Double declared in <root>.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:<root> fileName:/whenByFloatingPoint.kt
RETURN type=kotlin.Nothing from='public final fun testSmartCastInWhenSubject (x: kotlin.Any): kotlin.Int declared in <root>'
BLOCK type=kotlin.Int origin=WHEN
VAR IR_TEMPORARY_VARIABLE name:tmp1_subject type:kotlin.Double [val]
GET_VAR 'x: kotlin.Any declared in <root>.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:<root> fileName:/whenByFloatingPoint.kt
RETURN type=kotlin.Nothing from='public final fun testSmartCastInWhenCondition (x: kotlin.Double, y: kotlin.Any): kotlin.Int declared in <root>'
BLOCK type=kotlin.Int origin=WHEN
VAR IR_TEMPORARY_VARIABLE name:tmp2_subject type:kotlin.Double [val]
GET_VAR 'x: kotlin.Double declared in <root>.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:<root> fileName:/whenByFloatingPoint.kt
RETURN type=kotlin.Nothing from='public final fun testSmartCastInWhenConditionInBranch (x: kotlin.Any): kotlin.Int declared in <root>'
BLOCK type=kotlin.Int origin=WHEN
VAR IR_TEMPORARY_VARIABLE name:tmp3_subject type:kotlin.Any [val]
GET_VAR 'x: kotlin.Any declared in <root>.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:<root> fileName:/whenByFloatingPoint.kt
RETURN type=kotlin.Nothing from='public final fun testSmartCastToDifferentTypes (x: kotlin.Any, y: kotlin.Any): kotlin.Int declared in <root>'
BLOCK type=kotlin.Int origin=WHEN
VAR IR_TEMPORARY_VARIABLE name:tmp4_subject type:kotlin.Double [val]
GET_VAR 'x: kotlin.Any declared in <root>.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:<root> fileName:/whenByFloatingPoint.kt
RETURN type=kotlin.Nothing from='public final fun testWithPrematureExitInConditionSubexpression (x: kotlin.Any): kotlin.Int declared in <root>'
BLOCK type=kotlin.Int origin=WHEN
VAR IR_TEMPORARY_VARIABLE name:tmp5_subject type:kotlin.Any [val]
GET_VAR 'x: kotlin.Any declared in <root>.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
+2
View File
@@ -24,6 +24,7 @@ FILE fqName:<root> fileName:/when.kt
RETURN type=kotlin.Nothing from='public final fun testWithSubject (x: kotlin.Any?): kotlin.String declared in <root>'
BLOCK type=kotlin.String origin=WHEN
VAR IR_TEMPORARY_VARIABLE name:tmp0_subject type:kotlin.Any? [val]
GET_VAR 'x: kotlin.Any? declared in <root>.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:<root> fileName:/when.kt
RETURN type=kotlin.Nothing from='public final fun testComma (x: kotlin.Int): kotlin.String declared in <root>'
BLOCK type=kotlin.String origin=WHEN
VAR IR_TEMPORARY_VARIABLE name:tmp1_subject type:kotlin.Int [val]
GET_VAR 'x: kotlin.Int declared in <root>.testComma' type=kotlin.Int origin=null
WHEN type=kotlin.String origin=WHEN
BRANCH
if: WHEN type=kotlin.Boolean origin=OROR
@@ -4,6 +4,7 @@ FILE fqName:<root> 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 <root>.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
@@ -4,6 +4,7 @@ FILE fqName:<root> 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 <root>.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
@@ -8,6 +8,7 @@ FILE fqName:<root> fileName:/whenUnusedExpression.kt
if: GET_VAR 'b: kotlin.Boolean declared in <root>.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 <root>.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
@@ -13,6 +13,7 @@ FILE fqName:<root> 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 <root>' 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:<root> 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 <root>' 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:<root> 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 <root>' 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:<root> 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 <root>' 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