[FIR] Complete data-flow analysis for all control-flow graph nodes

There are conditions where the data-flow analysis for a control-flow
graph node is delayed. Make sure that when completing a graph, all nodes
within the graph have completed their data-flow analysis.

^KT-61794 Fixed
This commit is contained in:
Brian Norman
2023-09-22 12:59:25 -05:00
committed by Space Team
parent f2fb237212
commit 23bdfd226f
9 changed files with 63 additions and 18 deletions
@@ -7,10 +7,7 @@ package org.jetbrains.kotlin.fir
import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference
import org.jetbrains.kotlin.fir.resolve.dfa.FirControlFlowGraphReferenceImpl
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.CFGNode
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.ControlFlowGraph
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.GraphEnterNodeMarker
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.GraphExitNodeMarker
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.*
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
import org.jetbrains.kotlin.test.Assertions
@@ -41,6 +38,7 @@ class FirCfgConsistencyChecker(private val assertions: Assertions) : FirVisitorV
assertions.assertContainsElements(from.followingNodes, node)
}
assertions.assertFalse(node.followingNodes.isEmpty() && node.previousNodes.isEmpty()) { "Unconnected CFG node: $node" }
assertions.assertTrue(node is ClassExitNode || node.flowInitialized) { "All nodes must have a flow: $node" }
}
}