diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeVariablesData.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeVariablesData.kt index 51d3cf64d16..8e79f20be6d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeVariablesData.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeVariablesData.kt @@ -138,8 +138,7 @@ class PseudocodeVariablesData(val pseudocode: Pseudocode, private val bindingCon enterInitState = getDefaultValueForInitializers(variable, instruction, blockScopeVariableInfo) } if (!enterInitState.mayBeInitialized() || !enterInitState.isDeclared) { - val isInitialized = enterInitState.mayBeInitialized() - val variableDeclarationInfo = VariableControlFlowState.create(isInitialized, true) + val variableDeclarationInfo = VariableControlFlowState.create(enterInitState.initState, isDeclared = true) exitInstructionData.put(variable, variableDeclarationInfo) } } diff --git a/compiler/testData/cfg-variables/bugs/doWhileNotDefined.instructions b/compiler/testData/cfg-variables/bugs/doWhileNotDefined.instructions index 4c237530648..a823b77e469 100644 --- a/compiler/testData/cfg-variables/bugs/doWhileNotDefined.instructions +++ b/compiler/testData/cfg-variables/bugs/doWhileNotDefined.instructions @@ -11,7 +11,7 @@ L0: v(cond1: Boolean) INIT: in: {} out: {cond1=D} magic[FAKE_INITIALIZER](cond1: Boolean) -> INIT: in: {cond1=D} out: {cond1=D} w(cond1|) INIT: in: {cond1=D} out: {cond1=ID} - 2 mark({ do { if (cond1) continue val cond2 = false } while (cond2) }) INIT: in: {cond1=ID} out: {cond1=ID} USE: in: {cond1=READ} out: {cond1=READ} + 2 mark({ do { if (cond1) continue val cond2 = false } while (cond2) }) INIT: in: {cond1=ID} out: {cond1=ID} USE: in: {cond1=READ} out: {cond1=READ} 3 mark(do { if (cond1) continue val cond2 = false } while (cond2)) L2 [loop entry point]: L4 [body entry point]: @@ -19,19 +19,19 @@ L4 [body entry point]: mark(if (cond1) continue) r(cond1) -> jf(L7|) - jmp(L6) USE: in: {cond1=READ, cond2=READ} out: {cond1=READ, cond2=READ} + jmp(L6) USE: in: {cond1=READ, cond2=READ} out: {cond1=READ, cond2=READ} - jmp(L8) L7 [else branch]: read (Unit) INIT: in: {cond1=ID, cond2=I?} out: {cond1=ID, cond2=I?} L8 ['if' expression result]: merge(if (cond1) continue|!) -> - v(val cond2 = false) INIT: in: {cond1=ID, cond2=I?} out: {cond1=ID, cond2=ID} - r(false) -> INIT: in: {cond1=ID, cond2=ID} out: {cond1=ID, cond2=ID} - w(cond2|) + v(val cond2 = false) INIT: in: {cond1=ID, cond2=I?} out: {cond1=ID, cond2=I?D} + r(false) -> INIT: in: {cond1=ID, cond2=I?D} out: {cond1=ID, cond2=I?D} + w(cond2|) INIT: in: {cond1=ID, cond2=I?D} out: {cond1=ID, cond2=ID} L5 [body exit point]: L6 [condition entry point]: r(cond2) -> INIT: in: {cond1=ID, cond2=I?} out: {cond1=ID, cond2=I?} - jt(L2|) USE: in: {cond1=READ, cond2=READ} out: {cond1=READ, cond2=READ} + jt(L2|) USE: in: {cond1=READ, cond2=READ} out: {cond1=READ, cond2=READ} L3 [loop exit point]: read (Unit) L1: @@ -39,5 +39,5 @@ L1: error: INIT: in: {} out: {} sink: - INIT: in: {cond1=I?} out: {cond1=I?} USE: in: {} out: {} + INIT: in: {cond1=I?} out: {cond1=I?} USE: in: {} out: {} ===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/doWhileScope.instructions b/compiler/testData/cfg-variables/lexicalScopes/doWhileScope.instructions index 3941bd81b81..41dca936042 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/doWhileScope.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/doWhileScope.instructions @@ -11,21 +11,21 @@ L0: 1 INIT: in: {} out: {} 2 mark({ "before" do { var a = 2 } while (a > 0) "after" }) mark("before") - r("before") -> USE: in: {} out: {} + r("before") -> USE: in: {} out: {} 3 mark(do { var a = 2 } while (a > 0)) L2 [loop entry point]: L4 [body entry point]: mark({ var a = 2 }) INIT: in: {a=I?} out: {a=I?} - v(var a = 2) INIT: in: {a=I?} out: {a=ID} - r(2) -> INIT: in: {a=ID} out: {a=ID} - w(a|) + v(var a = 2) INIT: in: {a=I?} out: {a=I?D} + r(2) -> INIT: in: {a=I?D} out: {a=I?D} + w(a|) INIT: in: {a=I?D} out: {a=ID} L5 [body exit point]: L6 [condition entry point]: - r(a) -> + r(a) -> INIT: in: {a=ID} out: {a=ID} r(0) -> mark(a > 0) call(a > 0, compareTo|, ) -> - jt(L2|) USE: in: {a=READ} out: {a=READ} + jt(L2|) USE: in: {a=READ} out: {a=READ} L3 [loop exit point]: read (Unit) 2 mark("after") INIT: in: {} out: {} @@ -35,5 +35,5 @@ L1: error: sink: - USE: in: {} out: {} + USE: in: {} out: {} ===================== \ No newline at end of file