[FIR] Local variable assignment must be propagated before loops
When performing lookahead for local variable assignments, make sure assignments taking place within loops are being propagated before loops. This makes sure smartcasts within non-inline declarations before the loop are disallowed. ^KT-63867 Fixed
This commit is contained in:
+3
@@ -333,6 +333,9 @@ internal class FirLocalVariableAssignmentAnalyzer {
|
||||
override fun visitLoop(loop: FirLoop, data: MiniCfgData) {
|
||||
val entry = data.flow
|
||||
val assignedInside = visitElementWithLexicalScope(loop, data)
|
||||
// Now that the inner variables have been discarded, the rest can be propagated to prevent smartcasts
|
||||
// in declarations that came before this loop.
|
||||
entry.recordAssignments(assignedInside)
|
||||
// All forks in the loop should have the same set of variables assigned later, equal to the set
|
||||
// at the start of the loop.
|
||||
data.flow.recordAssignments(assignedInside)
|
||||
|
||||
Reference in New Issue
Block a user