FIR: thread control flow through anonymous object init blocks

^KT-39646 Fixed
This commit is contained in:
pyos
2021-11-18 14:31:22 +01:00
committed by TeamCityServer
parent 19031c88d9
commit a1be855d17
17 changed files with 506 additions and 431 deletions
@@ -20,7 +20,7 @@ fun <D> ControlFlowGraph.traverse(
) {
for (node in getNodesInOrder(direction)) {
node.accept(visitor, data)
(node as? CFGNodeWithCfgOwner<*>)?.subGraphs?.forEach { it.traverse(direction, visitor, data) }
(node as? CFGNodeWithSubgraphs<*>)?.subGraphs?.forEach { it.traverse(direction, visitor, data) }
}
}
@@ -61,7 +61,7 @@ private fun <I> ControlFlowGraph.collectDataForNodeInternal(
) {
val nodes = getNodesInOrder(direction)
for (node in nodes) {
if (visitSubGraphs && direction == TraverseDirection.Backward && node is CFGNodeWithCfgOwner<*>) {
if (visitSubGraphs && direction == TraverseDirection.Backward && node is CFGNodeWithSubgraphs<*>) {
node.subGraphs.forEach { it.collectDataForNodeInternal(direction, initialInfo, visitor, nodeMap, changed) }
}
val previousNodes = when (direction) {
@@ -85,7 +85,7 @@ private fun <I> ControlFlowGraph.collectDataForNodeInternal(
if (hasChanged) {
nodeMap[node] = newData
}
if (visitSubGraphs && direction == TraverseDirection.Forward && node is CFGNodeWithCfgOwner<*>) {
if (visitSubGraphs && direction == TraverseDirection.Forward && node is CFGNodeWithSubgraphs<*>) {
node.subGraphs.forEach { it.collectDataForNodeInternal(direction, initialInfo, visitor, nodeMap, changed) }
}
}
@@ -6,7 +6,7 @@
package org.jetbrains.kotlin.fir.analysis.cfa.util
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.CFGNode
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.CFGNodeWithCfgOwner
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.CFGNodeWithSubgraphs
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.ControlFlowGraph
fun ControlFlowGraph.getEnterNode(direction: TraverseDirection): CFGNode<*> = when (direction) {
@@ -42,7 +42,7 @@ val CFGNode<*>.followingCfgNodes: List<CFGNode<*>>
val kind = outgoingEdges.getValue(it).kind
kind.usedInCfa && !kind.isDead
}
(this as? CFGNodeWithCfgOwner<*>)?.subGraphs?.mapTo(nodes) { it.enterNode }
(this as? CFGNodeWithSubgraphs<*>)?.subGraphs?.mapTo(nodes) { it.enterNode }
return nodes
}