-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIR] Propagate variables initialized in loops to parent statements
When checking local variables initialization, there is a look-ahead pass that finds variables declared within repeatable statements. This is used to reset initialization information from certain control-flow graph paths when calculating if a variable is correctly initialized. Loops where not correctly propagating variables to outer repeatable statements, which caused problems for certain nested structures with jumps. ^KT-69494 Fixed (cherry picked from commit b450bd4)
- Loading branch information
1 parent
e9ad2a1
commit a1167e1
Showing
9 changed files
with
95 additions
and
48 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
...el/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
...c/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
...en/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
...ests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
compiler/testData/diagnostics/tests/controlFlowAnalysis/reassignmenGraphLoop.fir.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
fun test(loop: Boolean) { | ||
while (loop) { | ||
try { | ||
do { | ||
run<Unit> { | ||
val a: String | ||
if (loop) { | ||
a = "" | ||
} else { | ||
a = "" | ||
} | ||
} | ||
} while (loop) | ||
} catch (e: Exception) { | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
compiler/testData/diagnostics/tests/controlFlowAnalysis/reassignmenGraphLoop.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
fun test(loop: Boolean) { | ||
while (loop) { | ||
try { | ||
do { | ||
run<Unit> { | ||
val <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>a<!>: String | ||
if (loop) { | ||
<!UNUSED_VALUE!>a =<!> "" | ||
} else { | ||
<!UNUSED_VALUE!>a =<!> "" | ||
} | ||
} | ||
} while (loop) | ||
} catch (e: Exception) { | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.