From 84787013dd8e7e67a8fae76eef39057cdc3f3199 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 30 Aug 2019 11:08:38 +0300 Subject: [PATCH] [FIR] Fix CFG form for boolean operators --- .../resolve/dfa/FirDataFlowAnalyzerImpl.kt | 16 +- .../fir/resolve/dfa/cfg/ControlFlowGraph.kt | 2 + .../dfa/cfg/ControlFlowGraphBuilder.kt | 28 +- .../dfa/cfg/ControlFlowGraphNodeBuilder.kt | 5 + .../dfa/cfg/ControlFlowGraphRenderer.kt | 2 + .../transformers/FirBodyResolveTransformer.kt | 1 - .../testData/resolve/cfg/binaryOperations.dot | 304 ++++---- .../cfg/booleanOperatorsWithConsts.dot | 718 +++++++++--------- .../fir/resolve/testData/resolve/cfg/when.dot | 48 +- .../resolve/smartcasts/booleanOperators.dot | 566 +++++++------- .../testData/resolve/smartcasts/casts.dot | 290 +++---- 11 files changed, 1025 insertions(+), 955 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzerImpl.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzerImpl.kt index ba4f078e0c6..64c2fa647c4 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzerImpl.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzerImpl.kt @@ -491,9 +491,11 @@ class FirDataFlowAnalyzerImpl(transformer: FirBodyResolveTransformer) : FirDataF } override fun exitLeftBinaryAndArgument(binaryLogicExpression: FirBinaryLogicExpression) { - val node = graphBuilder.exitLeftBinaryAndArgument(binaryLogicExpression).passFlow(false) - val leftOperandVariable = getVariable(node.previousNodes.first().fir) - node.flow = logicSystem.approveFactsInsideFlow(leftOperandVariable eq True, node.flow).also { it.freeze() } + val (leftNode, rightNode) = graphBuilder.exitLeftBinaryAndArgument(binaryLogicExpression) + leftNode.passFlow() + rightNode.passFlow(false) + val leftOperandVariable = getVariable(leftNode.previousNodes.first().fir) + rightNode.flow = logicSystem.approveFactsInsideFlow(leftOperandVariable eq True, rightNode.flow).also { it.freeze() } } override fun exitBinaryAnd(binaryLogicExpression: FirBinaryLogicExpression) { @@ -534,9 +536,11 @@ class FirDataFlowAnalyzerImpl(transformer: FirBodyResolveTransformer) : FirDataF } override fun exitLeftBinaryOrArgument(binaryLogicExpression: FirBinaryLogicExpression) { - val node = graphBuilder.exitLeftBinaryOrArgument(binaryLogicExpression).passFlow(false) - val leftOperandVariable = getVariable(node.previousNodes.first().fir) - node.flow = logicSystem.approveFactsInsideFlow(leftOperandVariable eq False, node.flow).also { it.freeze() } + val (leftNode, rightNode) = graphBuilder.exitLeftBinaryOrArgument(binaryLogicExpression) + leftNode.passFlow() + rightNode.passFlow(false) + val leftOperandVariable = getVariable(leftNode.previousNodes.first().fir) + rightNode.flow = logicSystem.approveFactsInsideFlow(leftOperandVariable eq False, rightNode.flow).also { it.freeze() } } override fun exitBinaryOr(binaryLogicExpression: FirBinaryLogicExpression) { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt index d6135cd9ce6..c9d0d2384a8 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt @@ -103,10 +103,12 @@ abstract class AbstractBinaryExitNode(owner: ControlFlowGraph, l class BinaryAndEnterNode(owner: ControlFlowGraph, override val fir: FirBinaryLogicExpression, level: Int) : CFGNode(owner, level), EnterNode class BinaryAndExitLeftOperandNode(owner: ControlFlowGraph, override val fir: FirBinaryLogicExpression, level: Int) : CFGNode(owner, level) +class BinaryAndEnterRightOperandNode(owner: ControlFlowGraph, override val fir: FirBinaryLogicExpression, level: Int) : CFGNode(owner, level) class BinaryAndExitNode(owner: ControlFlowGraph, override val fir: FirBinaryLogicExpression, level: Int) : AbstractBinaryExitNode(owner, level), ExitNode class BinaryOrEnterNode(owner: ControlFlowGraph, override val fir: FirBinaryLogicExpression, level: Int) : CFGNode(owner, level), EnterNode class BinaryOrExitLeftOperandNode(owner: ControlFlowGraph, override val fir: FirBinaryLogicExpression, level: Int) : CFGNode(owner, level) +class BinaryOrEnterRightOperandNode(owner: ControlFlowGraph, override val fir: FirBinaryLogicExpression, level: Int) : CFGNode(owner, level) class BinaryOrExitNode(owner: ControlFlowGraph, override val fir: FirBinaryLogicExpression, level: Int) : AbstractBinaryExitNode(owner, level), ExitNode // ----------------------------------- Operator call ----------------------------------- diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt index 79e253f53f0..e6d4b55d68e 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt @@ -312,15 +312,21 @@ class ControlFlowGraphBuilder : ControlFlowGraphNodeBuilder() { return createBinaryAndEnterNode(binaryLogicExpression).also { addNewSimpleNode(it) }.also { levelCounter++ } } - fun exitLeftBinaryAndArgument(binaryLogicExpression: FirBinaryLogicExpression): BinaryAndExitLeftOperandNode { + fun exitLeftBinaryAndArgument(binaryLogicExpression: FirBinaryLogicExpression): Pair { assert(binaryLogicExpression.kind == FirBinaryLogicExpression.OperationKind.AND) val lastNode = lastNodes.pop() val leftBooleanConstValue = lastNode.booleanConstValue - addEdge(lastNode, binaryAndExitNodes.top(), propagateDeadness = false, isDead = leftBooleanConstValue == true) - return createBinaryAndExitLeftOperandNode(binaryLogicExpression).also { - addEdge(lastNode, it, isDead = leftBooleanConstValue == false) + + val leftExitNode = createBinaryAndExitLeftOperandNode(binaryLogicExpression).also { + addEdge(lastNode, it) + addEdge(it, binaryAndExitNodes.top(), propagateDeadness = false, isDead = leftBooleanConstValue == true) + } + + val rightEnterNode = createBinaryAndEnterRightOperandNode(binaryLogicExpression).also { + addEdge(leftExitNode, it, isDead = leftBooleanConstValue == false) lastNodes.push(it) } + return leftExitNode to rightEnterNode } fun exitBinaryAnd(binaryLogicExpression: FirBinaryLogicExpression): BinaryAndExitNode { @@ -342,17 +348,23 @@ class ControlFlowGraphBuilder : ControlFlowGraphNodeBuilder() { }.also { levelCounter++ } } - fun exitLeftBinaryOrArgument(binaryLogicExpression: FirBinaryLogicExpression): BinaryOrExitLeftOperandNode { + fun exitLeftBinaryOrArgument(binaryLogicExpression: FirBinaryLogicExpression): Pair { levelCounter-- assert(binaryLogicExpression.kind == FirBinaryLogicExpression.OperationKind.OR) val previousNode = lastNodes.pop() val leftBooleanValue = previousNode.booleanConstValue - addEdge(previousNode, binaryOrExitNodes.top(), isDead = leftBooleanValue == false) - return createBinaryOrExitLeftOperandNode(binaryLogicExpression).also { - addEdge(previousNode, it, isDead = leftBooleanValue == true) + + val leftExitNode = createBinaryOrExitLeftOperandNode(binaryLogicExpression).also { + addEdge(previousNode, it) + addEdge(it, binaryOrExitNodes.top(), isDead = leftBooleanValue == false) + } + + val rightExitNode = createBinaryOrEnterRightOperandNode(binaryLogicExpression).also { + addEdge(leftExitNode, it, isDead = leftBooleanValue == true) lastNodes.push(it) levelCounter++ } + return leftExitNode to rightExitNode } fun exitBinaryOr(binaryLogicExpression: FirBinaryLogicExpression): BinaryOrExitNode { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphNodeBuilder.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphNodeBuilder.kt index f87ca110b11..d88bf85c67b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphNodeBuilder.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphNodeBuilder.kt @@ -161,4 +161,9 @@ abstract class ControlFlowGraphNodeBuilder { protected fun createBinaryAndExitLeftOperandNode(fir: FirBinaryLogicExpression): BinaryAndExitLeftOperandNode = BinaryAndExitLeftOperandNode(graph, fir, levelCounter) + protected fun createBinaryAndEnterRightOperandNode(fir: FirBinaryLogicExpression): BinaryAndEnterRightOperandNode = + BinaryAndEnterRightOperandNode(graph, fir, levelCounter) + + protected fun createBinaryOrEnterRightOperandNode(fir: FirBinaryLogicExpression): BinaryOrEnterRightOperandNode = + BinaryOrEnterRightOperandNode(graph, fir, levelCounter) } \ No newline at end of file diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphRenderer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphRenderer.kt index a9ab53e3e04..b9c009257cc 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphRenderer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphRenderer.kt @@ -134,9 +134,11 @@ fun CFGNode<*>.render(): String = is BinaryAndEnterNode -> "Enter &&" is BinaryAndExitLeftOperandNode -> "Exit left part of &&" + is BinaryAndEnterRightOperandNode -> "Enter right part of &&" is BinaryAndExitNode -> "Exit &&" is BinaryOrEnterNode -> "Enter ||" is BinaryOrExitLeftOperandNode -> "Exit left part of ||" + is BinaryOrEnterRightOperandNode -> "Enter right part of ||" is BinaryOrExitNode -> "Exit ||" is PropertyEnterNode -> "Enter property" diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt index d9103608e9c..a6ac18012b1 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt @@ -517,7 +517,6 @@ open class FirBodyResolveTransformer( if (whenExpression.calleeReference is FirResolvedCallableReference && whenExpression.resultType !is FirImplicitTypeRef) { return whenExpression.compose() } - dataFlowAnalyzer.enterWhenExpression(whenExpression) return withScopeCleanup(localScopes) with@{ if (whenExpression.subjectVariable != null) { diff --git a/compiler/fir/resolve/testData/resolve/cfg/binaryOperations.dot b/compiler/fir/resolve/testData/resolve/cfg/binaryOperations.dot index 127dff7a2ce..29d49fbc3b5 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/binaryOperations.dot +++ b/compiler/fir/resolve/testData/resolve/cfg/binaryOperations.dot @@ -20,34 +20,35 @@ digraph binaryOperations_kt { 4 [label="Enter ||"]; 5 [label="Access variable R|/b1|"]; 6 [label="Exit left part of ||"]; - 7 [label="Access variable R|/b2|"]; - 8 [label="Exit ||"]; + 7 [label="Enter right part of ||"]; + 8 [label="Access variable R|/b2|"]; + 9 [label="Exit ||"]; } - 9 [label="Exit when branch condition"]; + 10 [label="Exit when branch condition"]; } subgraph cluster_5 { color=blue - 10 [label="Enter block"]; - 11 [label="Const: Int(1)"]; - 12 [label="Exit block"]; + 11 [label="Enter block"]; + 12 [label="Const: Int(1)"]; + 13 [label="Exit block"]; } - 13 [label="Exit when branch result"]; + 14 [label="Exit when branch result"]; subgraph cluster_6 { color=blue - 14 [label="Enter when branch condition else"]; - 15 [label="Exit when branch condition"]; + 15 [label="Enter when branch condition else"]; + 16 [label="Exit when branch condition"]; } subgraph cluster_7 { color=blue - 16 [label="Enter block"]; - 17 [label="Exit block"]; + 17 [label="Enter block"]; + 18 [label="Exit block"]; } - 18 [label="Exit when branch result"]; - 19 [label="Exit when"]; + 19 [label="Exit when branch result"]; + 20 [label="Exit when"]; } - 20 [label="Exit block"]; + 21 [label="Exit block"]; } - 21 [label="Exit function test_1" style="filled" fillcolor=red]; + 22 [label="Exit function test_1" style="filled" fillcolor=red]; } 0 -> {1}; @@ -55,250 +56,261 @@ digraph binaryOperations_kt { 2 -> {3}; 3 -> {4}; 4 -> {5}; - 5 -> {8 6}; - 6 -> {7}; + 5 -> {6}; + 6 -> {9 7}; 7 -> {8}; 8 -> {9}; - 9 -> {10 14}; - 10 -> {11}; + 9 -> {10}; + 10 -> {11 15}; 11 -> {12}; 12 -> {13}; - 13 -> {19}; - 14 -> {15}; + 13 -> {14}; + 14 -> {20}; 15 -> {16}; 16 -> {17}; 17 -> {18}; 18 -> {19}; 19 -> {20}; 20 -> {21}; + 21 -> {22}; subgraph cluster_8 { color=red - 22 [label="Enter function test_2" style="filled" fillcolor=red]; + 23 [label="Enter function test_2" style="filled" fillcolor=red]; subgraph cluster_9 { color=blue - 23 [label="Enter block"]; + 24 [label="Enter block"]; subgraph cluster_10 { color=blue - 24 [label="Enter when"]; + 25 [label="Enter when"]; subgraph cluster_11 { color=blue - 25 [label="Enter when branch condition "]; + 26 [label="Enter when branch condition "]; subgraph cluster_12 { color=blue - 26 [label="Enter &&"]; - 27 [label="Access variable R|/b1|"]; - 28 [label="Exit left part of &&"]; - 29 [label="Access variable R|/b2|"]; - 30 [label="Exit &&"]; + 27 [label="Enter &&"]; + 28 [label="Access variable R|/b1|"]; + 29 [label="Exit left part of &&"]; + 30 [label="Enter right part of &&"]; + 31 [label="Access variable R|/b2|"]; + 32 [label="Exit &&"]; } - 31 [label="Exit when branch condition"]; + 33 [label="Exit when branch condition"]; } subgraph cluster_13 { color=blue - 32 [label="Enter block"]; - 33 [label="Const: Int(1)"]; - 34 [label="Exit block"]; + 34 [label="Enter block"]; + 35 [label="Const: Int(1)"]; + 36 [label="Exit block"]; } - 35 [label="Exit when branch result"]; + 37 [label="Exit when branch result"]; subgraph cluster_14 { color=blue - 36 [label="Enter when branch condition else"]; - 37 [label="Exit when branch condition"]; + 38 [label="Enter when branch condition else"]; + 39 [label="Exit when branch condition"]; } subgraph cluster_15 { color=blue - 38 [label="Enter block"]; - 39 [label="Exit block"]; + 40 [label="Enter block"]; + 41 [label="Exit block"]; } - 40 [label="Exit when branch result"]; - 41 [label="Exit when"]; + 42 [label="Exit when branch result"]; + 43 [label="Exit when"]; } - 42 [label="Exit block"]; + 44 [label="Exit block"]; } - 43 [label="Exit function test_2" style="filled" fillcolor=red]; + 45 [label="Exit function test_2" style="filled" fillcolor=red]; } - 22 -> {23}; 23 -> {24}; 24 -> {25}; 25 -> {26}; 26 -> {27}; - 27 -> {30 28}; + 27 -> {28}; 28 -> {29}; - 29 -> {30}; + 29 -> {32 30}; 30 -> {31}; - 31 -> {32 36}; + 31 -> {32}; 32 -> {33}; - 33 -> {34}; + 33 -> {34 38}; 34 -> {35}; - 35 -> {41}; + 35 -> {36}; 36 -> {37}; - 37 -> {38}; + 37 -> {43}; 38 -> {39}; 39 -> {40}; 40 -> {41}; 41 -> {42}; 42 -> {43}; + 43 -> {44}; + 44 -> {45}; subgraph cluster_16 { color=red - 44 [label="Enter function test_3" style="filled" fillcolor=red]; + 46 [label="Enter function test_3" style="filled" fillcolor=red]; subgraph cluster_17 { color=blue - 45 [label="Enter block"]; + 47 [label="Enter block"]; subgraph cluster_18 { color=blue - 46 [label="Enter when"]; + 48 [label="Enter when"]; subgraph cluster_19 { color=blue - 47 [label="Enter when branch condition "]; + 49 [label="Enter when branch condition "]; subgraph cluster_20 { color=blue - 48 [label="Enter ||"]; + 50 [label="Enter ||"]; subgraph cluster_21 { color=blue - 49 [label="Enter &&"]; - 50 [label="Access variable R|/b1|"]; - 51 [label="Exit left part of &&"]; - 52 [label="Access variable R|/b2|"]; - 53 [label="Exit &&"]; + 51 [label="Enter &&"]; + 52 [label="Access variable R|/b1|"]; + 53 [label="Exit left part of &&"]; + 54 [label="Enter right part of &&"]; + 55 [label="Access variable R|/b2|"]; + 56 [label="Exit &&"]; } - 54 [label="Exit left part of ||"]; - 55 [label="Access variable R|/b3|"]; - 56 [label="Exit ||"]; + 57 [label="Exit left part of ||"]; + 58 [label="Enter right part of ||"]; + 59 [label="Access variable R|/b3|"]; + 60 [label="Exit ||"]; } - 57 [label="Exit when branch condition"]; + 61 [label="Exit when branch condition"]; } subgraph cluster_22 { color=blue - 58 [label="Enter block"]; - 59 [label="Const: Int(1)"]; - 60 [label="Exit block"]; + 62 [label="Enter block"]; + 63 [label="Const: Int(1)"]; + 64 [label="Exit block"]; } - 61 [label="Exit when branch result"]; + 65 [label="Exit when branch result"]; subgraph cluster_23 { color=blue - 62 [label="Enter when branch condition else"]; - 63 [label="Exit when branch condition"]; + 66 [label="Enter when branch condition else"]; + 67 [label="Exit when branch condition"]; } subgraph cluster_24 { color=blue - 64 [label="Enter block"]; - 65 [label="Exit block"]; + 68 [label="Enter block"]; + 69 [label="Exit block"]; } - 66 [label="Exit when branch result"]; - 67 [label="Exit when"]; + 70 [label="Exit when branch result"]; + 71 [label="Exit when"]; } - 68 [label="Exit block"]; + 72 [label="Exit block"]; } - 69 [label="Exit function test_3" style="filled" fillcolor=red]; + 73 [label="Exit function test_3" style="filled" fillcolor=red]; } - 44 -> {45}; - 45 -> {46}; 46 -> {47}; 47 -> {48}; 48 -> {49}; 49 -> {50}; - 50 -> {53 51}; + 50 -> {51}; 51 -> {52}; 52 -> {53}; 53 -> {56 54}; 54 -> {55}; 55 -> {56}; 56 -> {57}; - 57 -> {58 62}; + 57 -> {60 58}; 58 -> {59}; 59 -> {60}; 60 -> {61}; - 61 -> {67}; + 61 -> {62 66}; 62 -> {63}; 63 -> {64}; 64 -> {65}; - 65 -> {66}; + 65 -> {71}; 66 -> {67}; 67 -> {68}; 68 -> {69}; - - subgraph cluster_25 { - color=red - 70 [label="Enter function test_4" style="filled" fillcolor=red]; - subgraph cluster_26 { - color=blue - 71 [label="Enter block"]; - subgraph cluster_27 { - color=blue - 72 [label="Enter when"]; - subgraph cluster_28 { - color=blue - 73 [label="Enter when branch condition "]; - subgraph cluster_29 { - color=blue - 74 [label="Enter ||"]; - 75 [label="Access variable R|/b1|"]; - 76 [label="Exit left part of ||"]; - subgraph cluster_30 { - color=blue - 77 [label="Enter &&"]; - 78 [label="Access variable R|/b2|"]; - 79 [label="Exit left part of &&"]; - 80 [label="Access variable R|/b3|"]; - 81 [label="Exit &&"]; - } - 82 [label="Exit ||"]; - } - 83 [label="Exit when branch condition"]; - } - subgraph cluster_31 { - color=blue - 84 [label="Enter block"]; - 85 [label="Const: Int(1)"]; - 86 [label="Exit block"]; - } - 87 [label="Exit when branch result"]; - subgraph cluster_32 { - color=blue - 88 [label="Enter when branch condition else"]; - 89 [label="Exit when branch condition"]; - } - subgraph cluster_33 { - color=blue - 90 [label="Enter block"]; - 91 [label="Exit block"]; - } - 92 [label="Exit when branch result"]; - 93 [label="Exit when"]; - } - 94 [label="Exit block"]; - } - 95 [label="Exit function test_4" style="filled" fillcolor=red]; - } - + 69 -> {70}; 70 -> {71}; 71 -> {72}; 72 -> {73}; - 73 -> {74}; + + subgraph cluster_25 { + color=red + 74 [label="Enter function test_4" style="filled" fillcolor=red]; + subgraph cluster_26 { + color=blue + 75 [label="Enter block"]; + subgraph cluster_27 { + color=blue + 76 [label="Enter when"]; + subgraph cluster_28 { + color=blue + 77 [label="Enter when branch condition "]; + subgraph cluster_29 { + color=blue + 78 [label="Enter ||"]; + 79 [label="Access variable R|/b1|"]; + 80 [label="Exit left part of ||"]; + 81 [label="Enter right part of ||"]; + subgraph cluster_30 { + color=blue + 82 [label="Enter &&"]; + 83 [label="Access variable R|/b2|"]; + 84 [label="Exit left part of &&"]; + 85 [label="Enter right part of &&"]; + 86 [label="Access variable R|/b3|"]; + 87 [label="Exit &&"]; + } + 88 [label="Exit ||"]; + } + 89 [label="Exit when branch condition"]; + } + subgraph cluster_31 { + color=blue + 90 [label="Enter block"]; + 91 [label="Const: Int(1)"]; + 92 [label="Exit block"]; + } + 93 [label="Exit when branch result"]; + subgraph cluster_32 { + color=blue + 94 [label="Enter when branch condition else"]; + 95 [label="Exit when branch condition"]; + } + subgraph cluster_33 { + color=blue + 96 [label="Enter block"]; + 97 [label="Exit block"]; + } + 98 [label="Exit when branch result"]; + 99 [label="Exit when"]; + } + 100 [label="Exit block"]; + } + 101 [label="Exit function test_4" style="filled" fillcolor=red]; + } + 74 -> {75}; - 75 -> {82 76}; + 75 -> {76}; 76 -> {77}; 77 -> {78}; - 78 -> {81 79}; + 78 -> {79}; 79 -> {80}; - 80 -> {81}; + 80 -> {88 81}; 81 -> {82}; 82 -> {83}; - 83 -> {84 88}; - 84 -> {85}; + 83 -> {84}; + 84 -> {87 85}; 85 -> {86}; 86 -> {87}; - 87 -> {93}; + 87 -> {88}; 88 -> {89}; - 89 -> {90}; + 89 -> {90 94}; 90 -> {91}; 91 -> {92}; 92 -> {93}; - 93 -> {94}; + 93 -> {99}; 94 -> {95}; + 95 -> {96}; + 96 -> {97}; + 97 -> {98}; + 98 -> {99}; + 99 -> {100}; + 100 -> {101}; } diff --git a/compiler/fir/resolve/testData/resolve/cfg/booleanOperatorsWithConsts.dot b/compiler/fir/resolve/testData/resolve/cfg/booleanOperatorsWithConsts.dot index f51dbdb1d45..3ce87a22e4b 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/booleanOperatorsWithConsts.dot +++ b/compiler/fir/resolve/testData/resolve/cfg/booleanOperatorsWithConsts.dot @@ -20,34 +20,35 @@ digraph booleanOperatorsWithConsts_kt { 4 [label="Enter ||"]; 5 [label="Access variable R|/b|"]; 6 [label="Exit left part of ||"]; - 7 [label="Const: Boolean(false)"]; - 8 [label="Exit ||"]; + 7 [label="Enter right part of ||"]; + 8 [label="Const: Boolean(false)"]; + 9 [label="Exit ||"]; } - 9 [label="Exit when branch condition"]; + 10 [label="Exit when branch condition"]; } subgraph cluster_5 { color=blue - 10 [label="Enter block"]; - 11 [label="Const: Int(1)"]; - 12 [label="Exit block"]; + 11 [label="Enter block"]; + 12 [label="Const: Int(1)"]; + 13 [label="Exit block"]; } - 13 [label="Exit when branch result"]; + 14 [label="Exit when branch result"]; subgraph cluster_6 { color=blue - 14 [label="Enter when branch condition else"]; - 15 [label="Exit when branch condition"]; + 15 [label="Enter when branch condition else"]; + 16 [label="Exit when branch condition"]; } subgraph cluster_7 { color=blue - 16 [label="Enter block"]; - 17 [label="Exit block"]; + 17 [label="Enter block"]; + 18 [label="Exit block"]; } - 18 [label="Exit when branch result"]; - 19 [label="Exit when"]; + 19 [label="Exit when branch result"]; + 20 [label="Exit when"]; } - 20 [label="Exit block"]; + 21 [label="Exit block"]; } - 21 [label="Exit function test_1" style="filled" fillcolor=red]; + 22 [label="Exit function test_1" style="filled" fillcolor=red]; } 0 -> {1}; @@ -55,518 +56,531 @@ digraph booleanOperatorsWithConsts_kt { 2 -> {3}; 3 -> {4}; 4 -> {5}; - 5 -> {8 6}; - 6 -> {7}; + 5 -> {6}; + 6 -> {9 7}; 7 -> {8}; 8 -> {9}; - 9 -> {10 14}; - 10 -> {11}; + 9 -> {10}; + 10 -> {11 15}; 11 -> {12}; 12 -> {13}; - 13 -> {19}; - 14 -> {15}; + 13 -> {14}; + 14 -> {20}; 15 -> {16}; 16 -> {17}; 17 -> {18}; 18 -> {19}; 19 -> {20}; 20 -> {21}; + 21 -> {22}; subgraph cluster_8 { color=red - 22 [label="Enter function test_2" style="filled" fillcolor=red]; + 23 [label="Enter function test_2" style="filled" fillcolor=red]; subgraph cluster_9 { color=blue - 23 [label="Enter block"]; + 24 [label="Enter block"]; subgraph cluster_10 { color=blue - 24 [label="Enter when"]; + 25 [label="Enter when"]; subgraph cluster_11 { color=blue - 25 [label="Enter when branch condition "]; + 26 [label="Enter when branch condition "]; subgraph cluster_12 { color=blue - 26 [label="Enter ||"]; - 27 [label="Const: Boolean(false)"]; - 28 [label="Exit left part of ||"]; - 29 [label="Access variable R|/b|"]; - 30 [label="Stub" style="filled" fillcolor=gray]; - 31 [label="Exit ||"]; + 27 [label="Enter ||"]; + 28 [label="Const: Boolean(false)"]; + 29 [label="Exit left part of ||"]; + 30 [label="Enter right part of ||"]; + 31 [label="Access variable R|/b|"]; + 32 [label="Stub" style="filled" fillcolor=gray]; + 33 [label="Exit ||"]; } - 32 [label="Exit when branch condition"]; + 34 [label="Exit when branch condition"]; } subgraph cluster_13 { color=blue - 33 [label="Enter block"]; - 34 [label="Const: Int(1)"]; - 35 [label="Exit block"]; + 35 [label="Enter block"]; + 36 [label="Const: Int(1)"]; + 37 [label="Exit block"]; } - 36 [label="Exit when branch result"]; + 38 [label="Exit when branch result"]; subgraph cluster_14 { color=blue - 37 [label="Enter when branch condition else"]; - 38 [label="Exit when branch condition"]; + 39 [label="Enter when branch condition else"]; + 40 [label="Exit when branch condition"]; } subgraph cluster_15 { color=blue - 39 [label="Enter block"]; - 40 [label="Exit block"]; + 41 [label="Enter block"]; + 42 [label="Exit block"]; } - 41 [label="Exit when branch result"]; - 42 [label="Exit when"]; + 43 [label="Exit when branch result"]; + 44 [label="Exit when"]; } - 43 [label="Exit block"]; + 45 [label="Exit block"]; } - 44 [label="Exit function test_2" style="filled" fillcolor=red]; + 46 [label="Exit function test_2" style="filled" fillcolor=red]; } - 22 -> {23}; 23 -> {24}; 24 -> {25}; 25 -> {26}; 26 -> {27}; 27 -> {28}; - 27 -> {30} [style=dotted]; 28 -> {29}; - 29 -> {31}; - 30 -> {31} [style=dotted]; - 31 -> {32}; - 32 -> {33 37}; + 29 -> {30}; + 29 -> {32} [style=dotted]; + 30 -> {31}; + 31 -> {33}; + 32 -> {33} [style=dotted]; 33 -> {34}; - 34 -> {35}; + 34 -> {35 39}; 35 -> {36}; - 36 -> {42}; + 36 -> {37}; 37 -> {38}; - 38 -> {39}; + 38 -> {44}; 39 -> {40}; 40 -> {41}; 41 -> {42}; 42 -> {43}; 43 -> {44}; + 44 -> {45}; + 45 -> {46}; subgraph cluster_16 { color=red - 45 [label="Enter function test_3" style="filled" fillcolor=red]; + 47 [label="Enter function test_3" style="filled" fillcolor=red]; subgraph cluster_17 { color=blue - 46 [label="Enter block"]; + 48 [label="Enter block"]; subgraph cluster_18 { color=blue - 47 [label="Enter when"]; + 49 [label="Enter when"]; subgraph cluster_19 { color=blue - 48 [label="Enter when branch condition "]; + 50 [label="Enter when branch condition "]; subgraph cluster_20 { color=blue - 49 [label="Enter ||"]; - 50 [label="Access variable R|/b|"]; - 51 [label="Exit left part of ||"]; - 52 [label="Const: Boolean(true)"]; - 53 [label="Exit ||"]; + 51 [label="Enter ||"]; + 52 [label="Access variable R|/b|"]; + 53 [label="Exit left part of ||"]; + 54 [label="Enter right part of ||"]; + 55 [label="Const: Boolean(true)"]; + 56 [label="Exit ||"]; } - 54 [label="Exit when branch condition"]; + 57 [label="Exit when branch condition"]; } subgraph cluster_21 { color=blue - 55 [label="Enter block"]; - 56 [label="Const: Int(1)"]; - 57 [label="Exit block"]; + 58 [label="Enter block"]; + 59 [label="Const: Int(1)"]; + 60 [label="Exit block"]; } - 58 [label="Exit when branch result"]; + 61 [label="Exit when branch result"]; subgraph cluster_22 { color=blue - 59 [label="Enter when branch condition else"]; - 60 [label="Exit when branch condition"]; + 62 [label="Enter when branch condition else"]; + 63 [label="Exit when branch condition"]; } subgraph cluster_23 { color=blue - 61 [label="Enter block"]; - 62 [label="Exit block"]; + 64 [label="Enter block"]; + 65 [label="Exit block"]; } - 63 [label="Exit when branch result"]; - 64 [label="Exit when"]; + 66 [label="Exit when branch result"]; + 67 [label="Exit when"]; } - 65 [label="Exit block"]; + 68 [label="Exit block"]; } - 66 [label="Exit function test_3" style="filled" fillcolor=red]; + 69 [label="Exit function test_3" style="filled" fillcolor=red]; } - 45 -> {46}; - 46 -> {47}; 47 -> {48}; 48 -> {49}; 49 -> {50}; - 50 -> {53 51}; + 50 -> {51}; 51 -> {52}; 52 -> {53}; - 53 -> {54}; - 54 -> {55 59}; + 53 -> {56 54}; + 54 -> {55}; 55 -> {56}; 56 -> {57}; - 57 -> {58}; - 58 -> {64}; + 57 -> {58 62}; + 58 -> {59}; 59 -> {60}; 60 -> {61}; - 61 -> {62}; + 61 -> {67}; 62 -> {63}; 63 -> {64}; 64 -> {65}; 65 -> {66}; + 66 -> {67}; + 67 -> {68}; + 68 -> {69}; subgraph cluster_24 { color=red - 67 [label="Enter function test_4" style="filled" fillcolor=red]; + 70 [label="Enter function test_4" style="filled" fillcolor=red]; subgraph cluster_25 { color=blue - 68 [label="Enter block"]; + 71 [label="Enter block"]; subgraph cluster_26 { color=blue - 69 [label="Enter when"]; + 72 [label="Enter when"]; subgraph cluster_27 { color=blue - 70 [label="Enter when branch condition "]; + 73 [label="Enter when branch condition "]; subgraph cluster_28 { color=blue - 71 [label="Enter ||"]; - 72 [label="Const: Boolean(true)"]; - 73 [label="Stub" style="filled" fillcolor=gray]; - 74 [label="Exit left part of ||" style="filled" fillcolor=gray]; - 75 [label="Access variable R|/b|" style="filled" fillcolor=gray]; - 76 [label="Exit ||"]; + 74 [label="Enter ||"]; + 75 [label="Const: Boolean(true)"]; + 76 [label="Exit left part of ||"]; + 77 [label="Stub" style="filled" fillcolor=gray]; + 78 [label="Enter right part of ||" style="filled" fillcolor=gray]; + 79 [label="Access variable R|/b|" style="filled" fillcolor=gray]; + 80 [label="Exit ||"]; } - 77 [label="Exit when branch condition"]; + 81 [label="Exit when branch condition"]; } subgraph cluster_29 { color=blue - 78 [label="Enter block"]; - 79 [label="Const: Int(1)"]; - 80 [label="Exit block"]; + 82 [label="Enter block"]; + 83 [label="Const: Int(1)"]; + 84 [label="Exit block"]; } - 81 [label="Exit when branch result"]; + 85 [label="Exit when branch result"]; subgraph cluster_30 { color=blue - 82 [label="Enter when branch condition else"]; - 83 [label="Exit when branch condition"]; + 86 [label="Enter when branch condition else"]; + 87 [label="Exit when branch condition"]; } subgraph cluster_31 { color=blue - 84 [label="Enter block"]; - 85 [label="Exit block"]; + 88 [label="Enter block"]; + 89 [label="Exit block"]; } - 86 [label="Exit when branch result"]; - 87 [label="Exit when"]; + 90 [label="Exit when branch result"]; + 91 [label="Exit when"]; } - 88 [label="Exit block"]; + 92 [label="Exit block"]; } - 89 [label="Exit function test_4" style="filled" fillcolor=red]; + 93 [label="Exit function test_4" style="filled" fillcolor=red]; } - 67 -> {68}; - 68 -> {69}; - 69 -> {70}; 70 -> {71}; 71 -> {72}; - 72 -> {76}; - 72 -> {73} [style=dotted]; - 73 -> {74} [style=dotted]; - 74 -> {75} [style=dotted]; - 75 -> {76} [style=dotted]; - 76 -> {77}; - 77 -> {78 82}; - 78 -> {79}; - 79 -> {80}; + 72 -> {73}; + 73 -> {74}; + 74 -> {75}; + 75 -> {76}; + 76 -> {80}; + 76 -> {77} [style=dotted]; + 77 -> {78} [style=dotted]; + 78 -> {79} [style=dotted]; + 79 -> {80} [style=dotted]; 80 -> {81}; - 81 -> {87}; + 81 -> {82 86}; 82 -> {83}; 83 -> {84}; 84 -> {85}; - 85 -> {86}; + 85 -> {91}; 86 -> {87}; 87 -> {88}; 88 -> {89}; - - subgraph cluster_32 { - color=red - 90 [label="Enter function test_5" style="filled" fillcolor=red]; - subgraph cluster_33 { - color=blue - 91 [label="Enter block"]; - subgraph cluster_34 { - color=blue - 92 [label="Enter when"]; - subgraph cluster_35 { - color=blue - 93 [label="Enter when branch condition "]; - subgraph cluster_36 { - color=blue - 94 [label="Enter &&"]; - 95 [label="Access variable R|/b|"]; - 96 [label="Exit left part of &&"]; - 97 [label="Const: Boolean(false)"]; - 98 [label="Exit &&"]; - } - 99 [label="Exit when branch condition"]; - } - subgraph cluster_37 { - color=blue - 100 [label="Enter block"]; - 101 [label="Const: Int(1)"]; - 102 [label="Exit block"]; - } - 103 [label="Exit when branch result"]; - subgraph cluster_38 { - color=blue - 104 [label="Enter when branch condition else"]; - 105 [label="Exit when branch condition"]; - } - subgraph cluster_39 { - color=blue - 106 [label="Enter block"]; - 107 [label="Exit block"]; - } - 108 [label="Exit when branch result"]; - 109 [label="Exit when"]; - } - 110 [label="Exit block"]; - } - 111 [label="Exit function test_5" style="filled" fillcolor=red]; - } - + 89 -> {90}; 90 -> {91}; 91 -> {92}; 92 -> {93}; - 93 -> {94}; + + subgraph cluster_32 { + color=red + 94 [label="Enter function test_5" style="filled" fillcolor=red]; + subgraph cluster_33 { + color=blue + 95 [label="Enter block"]; + subgraph cluster_34 { + color=blue + 96 [label="Enter when"]; + subgraph cluster_35 { + color=blue + 97 [label="Enter when branch condition "]; + subgraph cluster_36 { + color=blue + 98 [label="Enter &&"]; + 99 [label="Access variable R|/b|"]; + 100 [label="Exit left part of &&"]; + 101 [label="Enter right part of &&"]; + 102 [label="Const: Boolean(false)"]; + 103 [label="Exit &&"]; + } + 104 [label="Exit when branch condition"]; + } + subgraph cluster_37 { + color=blue + 105 [label="Enter block"]; + 106 [label="Const: Int(1)"]; + 107 [label="Exit block"]; + } + 108 [label="Exit when branch result"]; + subgraph cluster_38 { + color=blue + 109 [label="Enter when branch condition else"]; + 110 [label="Exit when branch condition"]; + } + subgraph cluster_39 { + color=blue + 111 [label="Enter block"]; + 112 [label="Exit block"]; + } + 113 [label="Exit when branch result"]; + 114 [label="Exit when"]; + } + 115 [label="Exit block"]; + } + 116 [label="Exit function test_5" style="filled" fillcolor=red]; + } + 94 -> {95}; - 95 -> {98 96}; + 95 -> {96}; 96 -> {97}; 97 -> {98}; 98 -> {99}; - 99 -> {100 104}; - 100 -> {101}; + 99 -> {100}; + 100 -> {103 101}; 101 -> {102}; 102 -> {103}; - 103 -> {109}; - 104 -> {105}; + 103 -> {104}; + 104 -> {105 109}; 105 -> {106}; 106 -> {107}; 107 -> {108}; - 108 -> {109}; + 108 -> {114}; 109 -> {110}; 110 -> {111}; - - subgraph cluster_40 { - color=red - 112 [label="Enter function test_6" style="filled" fillcolor=red]; - subgraph cluster_41 { - color=blue - 113 [label="Enter block"]; - subgraph cluster_42 { - color=blue - 114 [label="Enter when"]; - subgraph cluster_43 { - color=blue - 115 [label="Enter when branch condition "]; - subgraph cluster_44 { - color=blue - 116 [label="Enter &&"]; - 117 [label="Const: Boolean(false)"]; - 118 [label="Stub" style="filled" fillcolor=gray]; - 119 [label="Exit left part of &&" style="filled" fillcolor=gray]; - 120 [label="Access variable R|/b|" style="filled" fillcolor=gray]; - 121 [label="Stub" style="filled" fillcolor=gray]; - 122 [label="Exit &&"]; - } - 123 [label="Exit when branch condition"]; - } - subgraph cluster_45 { - color=blue - 124 [label="Enter block"]; - 125 [label="Const: Int(1)"]; - 126 [label="Exit block"]; - } - 127 [label="Exit when branch result"]; - subgraph cluster_46 { - color=blue - 128 [label="Enter when branch condition else"]; - 129 [label="Exit when branch condition"]; - } - subgraph cluster_47 { - color=blue - 130 [label="Enter block"]; - 131 [label="Exit block"]; - } - 132 [label="Exit when branch result"]; - 133 [label="Exit when"]; - } - 134 [label="Exit block"]; - } - 135 [label="Exit function test_6" style="filled" fillcolor=red]; - } - + 111 -> {112}; 112 -> {113}; 113 -> {114}; 114 -> {115}; 115 -> {116}; - 116 -> {117}; - 117 -> {122}; - 117 -> {118} [style=dotted]; - 118 -> {119} [style=dotted]; - 119 -> {120} [style=dotted]; - 120 -> {121} [style=dotted]; - 121 -> {122} [style=dotted]; + + subgraph cluster_40 { + color=red + 117 [label="Enter function test_6" style="filled" fillcolor=red]; + subgraph cluster_41 { + color=blue + 118 [label="Enter block"]; + subgraph cluster_42 { + color=blue + 119 [label="Enter when"]; + subgraph cluster_43 { + color=blue + 120 [label="Enter when branch condition "]; + subgraph cluster_44 { + color=blue + 121 [label="Enter &&"]; + 122 [label="Const: Boolean(false)"]; + 123 [label="Exit left part of &&"]; + 124 [label="Stub" style="filled" fillcolor=gray]; + 125 [label="Enter right part of &&" style="filled" fillcolor=gray]; + 126 [label="Access variable R|/b|" style="filled" fillcolor=gray]; + 127 [label="Exit &&"]; + } + 128 [label="Exit when branch condition"]; + } + subgraph cluster_45 { + color=blue + 129 [label="Enter block"]; + 130 [label="Const: Int(1)"]; + 131 [label="Exit block"]; + } + 132 [label="Exit when branch result"]; + subgraph cluster_46 { + color=blue + 133 [label="Enter when branch condition else"]; + 134 [label="Exit when branch condition"]; + } + subgraph cluster_47 { + color=blue + 135 [label="Enter block"]; + 136 [label="Exit block"]; + } + 137 [label="Exit when branch result"]; + 138 [label="Exit when"]; + } + 139 [label="Exit block"]; + } + 140 [label="Exit function test_6" style="filled" fillcolor=red]; + } + + 117 -> {118}; + 118 -> {119}; + 119 -> {120}; + 120 -> {121}; + 121 -> {122}; 122 -> {123}; - 123 -> {124 128}; - 124 -> {125}; - 125 -> {126}; - 126 -> {127}; - 127 -> {133}; - 128 -> {129}; + 123 -> {127}; + 123 -> {124} [style=dotted]; + 124 -> {125} [style=dotted]; + 125 -> {126} [style=dotted]; + 126 -> {127} [style=dotted]; + 127 -> {128}; + 128 -> {129 133}; 129 -> {130}; 130 -> {131}; 131 -> {132}; - 132 -> {133}; + 132 -> {138}; 133 -> {134}; 134 -> {135}; - - subgraph cluster_48 { - color=red - 136 [label="Enter function test_7" style="filled" fillcolor=red]; - subgraph cluster_49 { - color=blue - 137 [label="Enter block"]; - subgraph cluster_50 { - color=blue - 138 [label="Enter when"]; - subgraph cluster_51 { - color=blue - 139 [label="Enter when branch condition "]; - subgraph cluster_52 { - color=blue - 140 [label="Enter &&"]; - 141 [label="Access variable R|/b|"]; - 142 [label="Exit left part of &&"]; - 143 [label="Const: Boolean(true)"]; - 144 [label="Exit &&"]; - } - 145 [label="Exit when branch condition"]; - } - subgraph cluster_53 { - color=blue - 146 [label="Enter block"]; - 147 [label="Const: Int(1)"]; - 148 [label="Exit block"]; - } - 149 [label="Exit when branch result"]; - subgraph cluster_54 { - color=blue - 150 [label="Enter when branch condition else"]; - 151 [label="Exit when branch condition"]; - } - subgraph cluster_55 { - color=blue - 152 [label="Enter block"]; - 153 [label="Exit block"]; - } - 154 [label="Exit when branch result"]; - 155 [label="Exit when"]; - } - 156 [label="Exit block"]; - } - 157 [label="Exit function test_7" style="filled" fillcolor=red]; - } - + 135 -> {136}; 136 -> {137}; 137 -> {138}; 138 -> {139}; 139 -> {140}; - 140 -> {141}; - 141 -> {144 142}; + + subgraph cluster_48 { + color=red + 141 [label="Enter function test_7" style="filled" fillcolor=red]; + subgraph cluster_49 { + color=blue + 142 [label="Enter block"]; + subgraph cluster_50 { + color=blue + 143 [label="Enter when"]; + subgraph cluster_51 { + color=blue + 144 [label="Enter when branch condition "]; + subgraph cluster_52 { + color=blue + 145 [label="Enter &&"]; + 146 [label="Access variable R|/b|"]; + 147 [label="Exit left part of &&"]; + 148 [label="Enter right part of &&"]; + 149 [label="Const: Boolean(true)"]; + 150 [label="Exit &&"]; + } + 151 [label="Exit when branch condition"]; + } + subgraph cluster_53 { + color=blue + 152 [label="Enter block"]; + 153 [label="Const: Int(1)"]; + 154 [label="Exit block"]; + } + 155 [label="Exit when branch result"]; + subgraph cluster_54 { + color=blue + 156 [label="Enter when branch condition else"]; + 157 [label="Exit when branch condition"]; + } + subgraph cluster_55 { + color=blue + 158 [label="Enter block"]; + 159 [label="Exit block"]; + } + 160 [label="Exit when branch result"]; + 161 [label="Exit when"]; + } + 162 [label="Exit block"]; + } + 163 [label="Exit function test_7" style="filled" fillcolor=red]; + } + + 141 -> {142}; 142 -> {143}; 143 -> {144}; 144 -> {145}; - 145 -> {146 150}; + 145 -> {146}; 146 -> {147}; - 147 -> {148}; + 147 -> {150 148}; 148 -> {149}; - 149 -> {155}; + 149 -> {150}; 150 -> {151}; - 151 -> {152}; + 151 -> {152 156}; 152 -> {153}; 153 -> {154}; 154 -> {155}; - 155 -> {156}; + 155 -> {161}; 156 -> {157}; - - subgraph cluster_56 { - color=red - 158 [label="Enter function test_8" style="filled" fillcolor=red]; - subgraph cluster_57 { - color=blue - 159 [label="Enter block"]; - subgraph cluster_58 { - color=blue - 160 [label="Enter when"]; - subgraph cluster_59 { - color=blue - 161 [label="Enter when branch condition "]; - subgraph cluster_60 { - color=blue - 162 [label="Enter &&"]; - 163 [label="Const: Boolean(true)"]; - 164 [label="Exit left part of &&"]; - 165 [label="Access variable R|/b|"]; - 166 [label="Stub" style="filled" fillcolor=gray]; - 167 [label="Exit &&"]; - } - 168 [label="Exit when branch condition"]; - } - subgraph cluster_61 { - color=blue - 169 [label="Enter block"]; - 170 [label="Const: Int(1)"]; - 171 [label="Exit block"]; - } - 172 [label="Exit when branch result"]; - subgraph cluster_62 { - color=blue - 173 [label="Enter when branch condition else"]; - 174 [label="Exit when branch condition"]; - } - subgraph cluster_63 { - color=blue - 175 [label="Enter block"]; - 176 [label="Exit block"]; - } - 177 [label="Exit when branch result"]; - 178 [label="Exit when"]; - } - 179 [label="Exit block"]; - } - 180 [label="Exit function test_8" style="filled" fillcolor=red]; - } - + 157 -> {158}; 158 -> {159}; 159 -> {160}; 160 -> {161}; 161 -> {162}; 162 -> {163}; - 163 -> {164}; - 163 -> {166} [style=dotted]; + + subgraph cluster_56 { + color=red + 164 [label="Enter function test_8" style="filled" fillcolor=red]; + subgraph cluster_57 { + color=blue + 165 [label="Enter block"]; + subgraph cluster_58 { + color=blue + 166 [label="Enter when"]; + subgraph cluster_59 { + color=blue + 167 [label="Enter when branch condition "]; + subgraph cluster_60 { + color=blue + 168 [label="Enter &&"]; + 169 [label="Const: Boolean(true)"]; + 170 [label="Exit left part of &&"]; + 171 [label="Enter right part of &&"]; + 172 [label="Access variable R|/b|"]; + 173 [label="Stub" style="filled" fillcolor=gray]; + 174 [label="Exit &&"]; + } + 175 [label="Exit when branch condition"]; + } + subgraph cluster_61 { + color=blue + 176 [label="Enter block"]; + 177 [label="Const: Int(1)"]; + 178 [label="Exit block"]; + } + 179 [label="Exit when branch result"]; + subgraph cluster_62 { + color=blue + 180 [label="Enter when branch condition else"]; + 181 [label="Exit when branch condition"]; + } + subgraph cluster_63 { + color=blue + 182 [label="Enter block"]; + 183 [label="Exit block"]; + } + 184 [label="Exit when branch result"]; + 185 [label="Exit when"]; + } + 186 [label="Exit block"]; + } + 187 [label="Exit function test_8" style="filled" fillcolor=red]; + } + 164 -> {165}; - 165 -> {167}; - 166 -> {167} [style=dotted]; + 165 -> {166}; + 166 -> {167}; 167 -> {168}; - 168 -> {169 173}; + 168 -> {169}; 169 -> {170}; 170 -> {171}; + 170 -> {173} [style=dotted]; 171 -> {172}; - 172 -> {178}; - 173 -> {174}; + 172 -> {174}; + 173 -> {174} [style=dotted]; 174 -> {175}; - 175 -> {176}; + 175 -> {176 180}; 176 -> {177}; 177 -> {178}; 178 -> {179}; - 179 -> {180}; + 179 -> {185}; + 180 -> {181}; + 181 -> {182}; + 182 -> {183}; + 183 -> {184}; + 184 -> {185}; + 185 -> {186}; + 186 -> {187}; } diff --git a/compiler/fir/resolve/testData/resolve/cfg/when.dot b/compiler/fir/resolve/testData/resolve/cfg/when.dot index d3e2b929919..a175eb6fe4e 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/when.dot +++ b/compiler/fir/resolve/testData/resolve/cfg/when.dot @@ -146,36 +146,37 @@ digraph when_kt { 50 [label="Access variable R|/x|"]; 51 [label="Type operator: x is A"]; 52 [label="Exit left part of &&"]; - 53 [label="Access variable R|/x|"]; - 54 [label="Type operator: x is B"]; - 55 [label="Exit &&"]; + 53 [label="Enter right part of &&"]; + 54 [label="Access variable R|/x|"]; + 55 [label="Type operator: x is B"]; + 56 [label="Exit &&"]; } - 56 [label="Exit when branch condition"]; + 57 [label="Exit when branch condition"]; } subgraph cluster_16 { color=blue - 57 [label="Enter block"]; - 58 [label="Access variable R|/x|"]; - 59 [label="Type operator: x is A"]; - 60 [label="Exit block"]; + 58 [label="Enter block"]; + 59 [label="Access variable R|/x|"]; + 60 [label="Type operator: x is A"]; + 61 [label="Exit block"]; } - 61 [label="Exit when branch result"]; + 62 [label="Exit when branch result"]; subgraph cluster_17 { color=blue - 62 [label="Enter when branch condition else"]; - 63 [label="Exit when branch condition"]; + 63 [label="Enter when branch condition else"]; + 64 [label="Exit when branch condition"]; } subgraph cluster_18 { color=blue - 64 [label="Enter block"]; - 65 [label="Exit block"]; + 65 [label="Enter block"]; + 66 [label="Exit block"]; } - 66 [label="Exit when branch result"]; - 67 [label="Exit when"]; + 67 [label="Exit when branch result"]; + 68 [label="Exit when"]; } - 68 [label="Exit block"]; + 69 [label="Exit block"]; } - 69 [label="Exit function test_2" style="filled" fillcolor=red]; + 70 [label="Exit function test_2" style="filled" fillcolor=red]; } 45 -> {46}; @@ -184,23 +185,24 @@ digraph when_kt { 48 -> {49}; 49 -> {50}; 50 -> {51}; - 51 -> {55 52}; - 52 -> {53}; + 51 -> {52}; + 52 -> {56 53}; 53 -> {54}; 54 -> {55}; 55 -> {56}; - 56 -> {57 62}; - 57 -> {58}; + 56 -> {57}; + 57 -> {58 63}; 58 -> {59}; 59 -> {60}; 60 -> {61}; - 61 -> {67}; - 62 -> {63}; + 61 -> {62}; + 62 -> {68}; 63 -> {64}; 64 -> {65}; 65 -> {66}; 66 -> {67}; 67 -> {68}; 68 -> {69}; + 69 -> {70}; } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/booleanOperators.dot b/compiler/fir/resolve/testData/resolve/smartcasts/booleanOperators.dot index e181b71f44f..9e2cef296e6 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/booleanOperators.dot +++ b/compiler/fir/resolve/testData/resolve/smartcasts/booleanOperators.dot @@ -53,40 +53,41 @@ digraph booleanOperators_kt { 13 [label="Access variable R|/x|"]; 14 [label="Type operator: x is B"]; 15 [label="Exit left part of &&"]; - 16 [label="Access variable R|/x|"]; - 17 [label="Type operator: x is C"]; - 18 [label="Exit &&"]; + 16 [label="Enter right part of &&"]; + 17 [label="Access variable R|/x|"]; + 18 [label="Type operator: x is C"]; + 19 [label="Exit &&"]; } - 19 [label="Exit when branch condition"]; + 20 [label="Exit when branch condition"]; } subgraph cluster_9 { color=blue - 20 [label="Enter block"]; - 21 [label="Access variable R|/x|"]; - 22 [label="Function call: R|/x|.R|/A.foo|()"]; - 23 [label="Access variable R|/x|"]; - 24 [label="Function call: R|/x|.R|/B.bar|()"]; - 25 [label="Access variable R|/x|"]; - 26 [label="Function call: R|/x|.R|/C.baz|()"]; - 27 [label="Exit block"]; + 21 [label="Enter block"]; + 22 [label="Access variable R|/x|"]; + 23 [label="Function call: R|/x|.R|/A.foo|()"]; + 24 [label="Access variable R|/x|"]; + 25 [label="Function call: R|/x|.R|/B.bar|()"]; + 26 [label="Access variable R|/x|"]; + 27 [label="Function call: R|/x|.R|/C.baz|()"]; + 28 [label="Exit block"]; } - 28 [label="Exit when branch result"]; + 29 [label="Exit when branch result"]; subgraph cluster_10 { color=blue - 29 [label="Enter when branch condition else"]; - 30 [label="Exit when branch condition"]; + 30 [label="Enter when branch condition else"]; + 31 [label="Exit when branch condition"]; } subgraph cluster_11 { color=blue - 31 [label="Enter block"]; - 32 [label="Exit block"]; + 32 [label="Enter block"]; + 33 [label="Exit block"]; } - 33 [label="Exit when branch result"]; - 34 [label="Exit when"]; + 34 [label="Exit when branch result"]; + 35 [label="Exit when"]; } - 35 [label="Exit block"]; + 36 [label="Exit block"]; } - 36 [label="Exit function test_1" style="filled" fillcolor=red]; + 37 [label="Exit function test_1" style="filled" fillcolor=red]; } 8 -> {9}; @@ -95,13 +96,13 @@ digraph booleanOperators_kt { 11 -> {12}; 12 -> {13}; 13 -> {14}; - 14 -> {18 15}; - 15 -> {16}; + 14 -> {15}; + 15 -> {19 16}; 16 -> {17}; 17 -> {18}; 18 -> {19}; - 19 -> {20 29}; - 20 -> {21}; + 19 -> {20}; + 20 -> {21 30}; 21 -> {22}; 22 -> {23}; 23 -> {24}; @@ -109,471 +110,482 @@ digraph booleanOperators_kt { 25 -> {26}; 26 -> {27}; 27 -> {28}; - 28 -> {34}; - 29 -> {30}; + 28 -> {29}; + 29 -> {35}; 30 -> {31}; 31 -> {32}; 32 -> {33}; 33 -> {34}; 34 -> {35}; 35 -> {36}; + 36 -> {37}; subgraph cluster_12 { color=red - 37 [label="Enter function test_2" style="filled" fillcolor=red]; + 38 [label="Enter function test_2" style="filled" fillcolor=red]; subgraph cluster_13 { color=blue - 38 [label="Enter block"]; + 39 [label="Enter block"]; subgraph cluster_14 { color=blue - 39 [label="Enter when"]; + 40 [label="Enter when"]; subgraph cluster_15 { color=blue - 40 [label="Enter when branch condition "]; + 41 [label="Enter when branch condition "]; subgraph cluster_16 { color=blue - 41 [label="Enter ||"]; - 42 [label="Access variable R|/x|"]; - 43 [label="Type operator: x is B"]; - 44 [label="Exit left part of ||"]; - 45 [label="Access variable R|/x|"]; - 46 [label="Type operator: x is C"]; - 47 [label="Exit ||"]; + 42 [label="Enter ||"]; + 43 [label="Access variable R|/x|"]; + 44 [label="Type operator: x is B"]; + 45 [label="Exit left part of ||"]; + 46 [label="Enter right part of ||"]; + 47 [label="Access variable R|/x|"]; + 48 [label="Type operator: x is C"]; + 49 [label="Exit ||"]; } - 48 [label="Exit when branch condition"]; + 50 [label="Exit when branch condition"]; } subgraph cluster_17 { color=blue - 49 [label="Enter block"]; - 50 [label="Access variable R|/x|"]; - 51 [label="Function call: R|/x|.R|/A.foo|()"]; + 51 [label="Enter block"]; 52 [label="Access variable R|/x|"]; - 53 [label="Function call: R|/x|.#()"]; + 53 [label="Function call: R|/x|.R|/A.foo|()"]; 54 [label="Access variable R|/x|"]; - 55 [label="Function call: R|/x|.#()"]; - 56 [label="Exit block"]; + 55 [label="Function call: R|/x|.#()"]; + 56 [label="Access variable R|/x|"]; + 57 [label="Function call: R|/x|.#()"]; + 58 [label="Exit block"]; } - 57 [label="Exit when branch result"]; + 59 [label="Exit when branch result"]; subgraph cluster_18 { color=blue - 58 [label="Enter when branch condition else"]; - 59 [label="Exit when branch condition"]; + 60 [label="Enter when branch condition else"]; + 61 [label="Exit when branch condition"]; } subgraph cluster_19 { color=blue - 60 [label="Enter block"]; - 61 [label="Exit block"]; + 62 [label="Enter block"]; + 63 [label="Exit block"]; } - 62 [label="Exit when branch result"]; - 63 [label="Exit when"]; + 64 [label="Exit when branch result"]; + 65 [label="Exit when"]; } - 64 [label="Exit block"]; + 66 [label="Exit block"]; } - 65 [label="Exit function test_2" style="filled" fillcolor=red]; + 67 [label="Exit function test_2" style="filled" fillcolor=red]; } - 37 -> {38}; 38 -> {39}; 39 -> {40}; 40 -> {41}; 41 -> {42}; 42 -> {43}; - 43 -> {47 44}; + 43 -> {44}; 44 -> {45}; - 45 -> {46}; + 45 -> {49 46}; 46 -> {47}; 47 -> {48}; - 48 -> {49 58}; + 48 -> {49}; 49 -> {50}; - 50 -> {51}; + 50 -> {51 60}; 51 -> {52}; 52 -> {53}; 53 -> {54}; 54 -> {55}; 55 -> {56}; 56 -> {57}; - 57 -> {63}; + 57 -> {58}; 58 -> {59}; - 59 -> {60}; + 59 -> {65}; 60 -> {61}; 61 -> {62}; 62 -> {63}; 63 -> {64}; 64 -> {65}; + 65 -> {66}; + 66 -> {67}; subgraph cluster_20 { color=red - 66 [label="Enter function test_3" style="filled" fillcolor=red]; + 68 [label="Enter function test_3" style="filled" fillcolor=red]; subgraph cluster_21 { color=blue - 67 [label="Enter block"]; + 69 [label="Enter block"]; subgraph cluster_22 { color=blue - 68 [label="Enter when"]; + 70 [label="Enter when"]; subgraph cluster_23 { color=blue - 69 [label="Enter when branch condition "]; - 70 [label="Access variable R|/x|"]; - 71 [label="Type operator: x !is A"]; - 72 [label="Function call: (R|/x| !is R|A|).R|kotlin/Boolean.not|()"]; - 73 [label="Exit when branch condition"]; + 71 [label="Enter when branch condition "]; + 72 [label="Access variable R|/x|"]; + 73 [label="Type operator: x !is A"]; + 74 [label="Function call: (R|/x| !is R|A|).R|kotlin/Boolean.not|()"]; + 75 [label="Exit when branch condition"]; } subgraph cluster_24 { color=blue - 74 [label="Enter block"]; - 75 [label="Access variable R|/x|"]; - 76 [label="Function call: R|/x|.R|/A.foo|()"]; - 77 [label="Exit block"]; + 76 [label="Enter block"]; + 77 [label="Access variable R|/x|"]; + 78 [label="Function call: R|/x|.R|/A.foo|()"]; + 79 [label="Exit block"]; } - 78 [label="Exit when branch result"]; + 80 [label="Exit when branch result"]; subgraph cluster_25 { color=blue - 79 [label="Enter when branch condition else"]; - 80 [label="Exit when branch condition"]; + 81 [label="Enter when branch condition else"]; + 82 [label="Exit when branch condition"]; } subgraph cluster_26 { color=blue - 81 [label="Enter block"]; - 82 [label="Exit block"]; + 83 [label="Enter block"]; + 84 [label="Exit block"]; } - 83 [label="Exit when branch result"]; - 84 [label="Exit when"]; + 85 [label="Exit when branch result"]; + 86 [label="Exit when"]; } - 85 [label="Exit block"]; + 87 [label="Exit block"]; } - 86 [label="Exit function test_3" style="filled" fillcolor=red]; + 88 [label="Exit function test_3" style="filled" fillcolor=red]; } - 66 -> {67}; - 67 -> {68}; 68 -> {69}; 69 -> {70}; 70 -> {71}; 71 -> {72}; 72 -> {73}; - 73 -> {74 79}; + 73 -> {74}; 74 -> {75}; - 75 -> {76}; + 75 -> {76 81}; 76 -> {77}; 77 -> {78}; - 78 -> {84}; + 78 -> {79}; 79 -> {80}; - 80 -> {81}; + 80 -> {86}; 81 -> {82}; 82 -> {83}; 83 -> {84}; 84 -> {85}; 85 -> {86}; + 86 -> {87}; + 87 -> {88}; subgraph cluster_27 { color=red - 87 [label="Enter function test_4" style="filled" fillcolor=red]; + 89 [label="Enter function test_4" style="filled" fillcolor=red]; subgraph cluster_28 { color=blue - 88 [label="Enter block"]; + 90 [label="Enter block"]; subgraph cluster_29 { color=blue - 89 [label="Enter when"]; + 91 [label="Enter when"]; subgraph cluster_30 { color=blue - 90 [label="Enter when branch condition "]; + 92 [label="Enter when branch condition "]; subgraph cluster_31 { color=blue - 91 [label="Enter ||"]; - 92 [label="Access variable R|/x|"]; - 93 [label="Type operator: x !is String"]; - 94 [label="Exit left part of ||"]; - 95 [label="Access variable R|/x|"]; - 96 [label="Access variable R|kotlin/String.length|"]; - 97 [label="Const: Int(0)"]; - 98 [label="Operator =="]; - 99 [label="Exit ||"]; + 93 [label="Enter ||"]; + 94 [label="Access variable R|/x|"]; + 95 [label="Type operator: x !is String"]; + 96 [label="Exit left part of ||"]; + 97 [label="Enter right part of ||"]; + 98 [label="Access variable R|/x|"]; + 99 [label="Access variable R|kotlin/String.length|"]; + 100 [label="Const: Int(0)"]; + 101 [label="Operator =="]; + 102 [label="Exit ||"]; } - 100 [label="Exit when branch condition"]; + 103 [label="Exit when branch condition"]; } subgraph cluster_32 { color=blue - 101 [label="Enter block"]; - 102 [label="Access variable R|/x|"]; - 103 [label="Access variable #"]; - 104 [label="Exit block"]; + 104 [label="Enter block"]; + 105 [label="Access variable R|/x|"]; + 106 [label="Access variable #"]; + 107 [label="Exit block"]; } - 105 [label="Exit when branch result"]; + 108 [label="Exit when branch result"]; subgraph cluster_33 { color=blue - 106 [label="Enter when branch condition else"]; - 107 [label="Exit when branch condition"]; + 109 [label="Enter when branch condition else"]; + 110 [label="Exit when branch condition"]; } subgraph cluster_34 { color=blue - 108 [label="Enter block"]; - 109 [label="Exit block"]; + 111 [label="Enter block"]; + 112 [label="Exit block"]; } - 110 [label="Exit when branch result"]; - 111 [label="Exit when"]; + 113 [label="Exit when branch result"]; + 114 [label="Exit when"]; } - 112 [label="Access variable R|/x|"]; - 113 [label="Access variable #"]; - 114 [label="Exit block"]; + 115 [label="Access variable R|/x|"]; + 116 [label="Access variable #"]; + 117 [label="Exit block"]; } - 115 [label="Exit function test_4" style="filled" fillcolor=red]; + 118 [label="Exit function test_4" style="filled" fillcolor=red]; } - 87 -> {88}; - 88 -> {89}; 89 -> {90}; 90 -> {91}; 91 -> {92}; 92 -> {93}; - 93 -> {99 94}; + 93 -> {94}; 94 -> {95}; 95 -> {96}; - 96 -> {97}; + 96 -> {102 97}; 97 -> {98}; 98 -> {99}; 99 -> {100}; - 100 -> {101 106}; + 100 -> {101}; 101 -> {102}; 102 -> {103}; - 103 -> {104}; + 103 -> {104 109}; 104 -> {105}; - 105 -> {111}; + 105 -> {106}; 106 -> {107}; 107 -> {108}; - 108 -> {109}; + 108 -> {114}; 109 -> {110}; 110 -> {111}; 111 -> {112}; 112 -> {113}; 113 -> {114}; 114 -> {115}; + 115 -> {116}; + 116 -> {117}; + 117 -> {118}; subgraph cluster_35 { color=red - 116 [label="Enter function test_5" style="filled" fillcolor=red]; + 119 [label="Enter function test_5" style="filled" fillcolor=red]; subgraph cluster_36 { color=blue - 117 [label="Enter block"]; + 120 [label="Enter block"]; subgraph cluster_37 { color=blue - 118 [label="Enter when"]; + 121 [label="Enter when"]; subgraph cluster_38 { color=blue - 119 [label="Enter when branch condition "]; + 122 [label="Enter when branch condition "]; subgraph cluster_39 { color=blue - 120 [label="Enter ||"]; - 121 [label="Access variable R|/x|"]; - 122 [label="Const: Null(null)"]; - 123 [label="Operator !="]; - 124 [label="Exit left part of ||"]; - 125 [label="Const: Boolean(false)"]; - 126 [label="Exit ||"]; + 123 [label="Enter ||"]; + 124 [label="Access variable R|/x|"]; + 125 [label="Const: Null(null)"]; + 126 [label="Operator !="]; + 127 [label="Exit left part of ||"]; + 128 [label="Enter right part of ||"]; + 129 [label="Const: Boolean(false)"]; + 130 [label="Exit ||"]; } - 127 [label="Exit when branch condition"]; + 131 [label="Exit when branch condition"]; } subgraph cluster_40 { color=blue - 128 [label="Enter block"]; - 129 [label="Access variable R|/x|"]; - 130 [label="Function call: R|/x|.#()"]; - 131 [label="Exit block"]; + 132 [label="Enter block"]; + 133 [label="Access variable R|/x|"]; + 134 [label="Function call: R|/x|.#()"]; + 135 [label="Exit block"]; } - 132 [label="Exit when branch result"]; + 136 [label="Exit when branch result"]; subgraph cluster_41 { color=blue - 133 [label="Enter when branch condition else"]; - 134 [label="Exit when branch condition"]; + 137 [label="Enter when branch condition else"]; + 138 [label="Exit when branch condition"]; } subgraph cluster_42 { color=blue - 135 [label="Enter block"]; - 136 [label="Exit block"]; + 139 [label="Enter block"]; + 140 [label="Exit block"]; } - 137 [label="Exit when branch result"]; - 138 [label="Exit when"]; + 141 [label="Exit when branch result"]; + 142 [label="Exit when"]; } - 139 [label="Exit block"]; + 143 [label="Exit block"]; } - 140 [label="Exit function test_5" style="filled" fillcolor=red]; + 144 [label="Exit function test_5" style="filled" fillcolor=red]; } - 116 -> {117}; - 117 -> {118}; - 118 -> {119}; 119 -> {120}; 120 -> {121}; 121 -> {122}; 122 -> {123}; - 123 -> {126 124}; + 123 -> {124}; 124 -> {125}; 125 -> {126}; 126 -> {127}; - 127 -> {128 133}; + 127 -> {130 128}; 128 -> {129}; 129 -> {130}; 130 -> {131}; - 131 -> {132}; - 132 -> {138}; + 131 -> {132 137}; + 132 -> {133}; 133 -> {134}; 134 -> {135}; 135 -> {136}; - 136 -> {137}; + 136 -> {142}; 137 -> {138}; 138 -> {139}; 139 -> {140}; - - subgraph cluster_43 { - color=red - 141 [label="Enter function test_6" style="filled" fillcolor=red]; - subgraph cluster_44 { - color=blue - 142 [label="Enter block"]; - subgraph cluster_45 { - color=blue - 143 [label="Enter when"]; - subgraph cluster_46 { - color=blue - 144 [label="Enter when branch condition "]; - subgraph cluster_47 { - color=blue - 145 [label="Enter ||"]; - 146 [label="Const: Boolean(false)"]; - 147 [label="Exit left part of ||"]; - 148 [label="Access variable R|/x|"]; - 149 [label="Const: Null(null)"]; - 150 [label="Operator !="]; - 151 [label="Stub" style="filled" fillcolor=gray]; - 152 [label="Exit ||"]; - } - 153 [label="Exit when branch condition"]; - } - subgraph cluster_48 { - color=blue - 154 [label="Enter block"]; - 155 [label="Access variable R|/x|"]; - 156 [label="Function call: R|/x|.#()"]; - 157 [label="Exit block"]; - } - 158 [label="Exit when branch result"]; - subgraph cluster_49 { - color=blue - 159 [label="Enter when branch condition else"]; - 160 [label="Exit when branch condition"]; - } - subgraph cluster_50 { - color=blue - 161 [label="Enter block"]; - 162 [label="Exit block"]; - } - 163 [label="Exit when branch result"]; - 164 [label="Exit when"]; - } - 165 [label="Exit block"]; - } - 166 [label="Exit function test_6" style="filled" fillcolor=red]; - } - + 140 -> {141}; 141 -> {142}; 142 -> {143}; 143 -> {144}; - 144 -> {145}; + + subgraph cluster_43 { + color=red + 145 [label="Enter function test_6" style="filled" fillcolor=red]; + subgraph cluster_44 { + color=blue + 146 [label="Enter block"]; + subgraph cluster_45 { + color=blue + 147 [label="Enter when"]; + subgraph cluster_46 { + color=blue + 148 [label="Enter when branch condition "]; + subgraph cluster_47 { + color=blue + 149 [label="Enter ||"]; + 150 [label="Const: Boolean(false)"]; + 151 [label="Exit left part of ||"]; + 152 [label="Enter right part of ||"]; + 153 [label="Access variable R|/x|"]; + 154 [label="Const: Null(null)"]; + 155 [label="Operator !="]; + 156 [label="Stub" style="filled" fillcolor=gray]; + 157 [label="Exit ||"]; + } + 158 [label="Exit when branch condition"]; + } + subgraph cluster_48 { + color=blue + 159 [label="Enter block"]; + 160 [label="Access variable R|/x|"]; + 161 [label="Function call: R|/x|.#()"]; + 162 [label="Exit block"]; + } + 163 [label="Exit when branch result"]; + subgraph cluster_49 { + color=blue + 164 [label="Enter when branch condition else"]; + 165 [label="Exit when branch condition"]; + } + subgraph cluster_50 { + color=blue + 166 [label="Enter block"]; + 167 [label="Exit block"]; + } + 168 [label="Exit when branch result"]; + 169 [label="Exit when"]; + } + 170 [label="Exit block"]; + } + 171 [label="Exit function test_6" style="filled" fillcolor=red]; + } + 145 -> {146}; 146 -> {147}; - 146 -> {151} [style=dotted]; 147 -> {148}; 148 -> {149}; 149 -> {150}; - 150 -> {152}; - 151 -> {152} [style=dotted]; + 150 -> {151}; + 151 -> {152}; + 151 -> {156} [style=dotted]; 152 -> {153}; - 153 -> {154 159}; + 153 -> {154}; 154 -> {155}; - 155 -> {156}; - 156 -> {157}; + 155 -> {157}; + 156 -> {157} [style=dotted]; 157 -> {158}; - 158 -> {164}; + 158 -> {159 164}; 159 -> {160}; 160 -> {161}; 161 -> {162}; 162 -> {163}; - 163 -> {164}; + 163 -> {169}; 164 -> {165}; 165 -> {166}; - - subgraph cluster_51 { - color=red - 167 [label="Enter function test_7" style="filled" fillcolor=red]; - subgraph cluster_52 { - color=blue - 168 [label="Enter block"]; - subgraph cluster_53 { - color=blue - 169 [label="Enter when"]; - subgraph cluster_54 { - color=blue - 170 [label="Enter when branch condition "]; - subgraph cluster_55 { - color=blue - 171 [label="Enter &&"]; - 172 [label="Access variable R|/x|"]; - 173 [label="Type operator: x is A"]; - 174 [label="Exit left part of &&"]; - 175 [label="Access variable R|/x|"]; - 176 [label="Function call: R|/x|.R|/A.bool|()"]; - 177 [label="Exit &&"]; - } - 178 [label="Exit when branch condition"]; - } - subgraph cluster_56 { - color=blue - 179 [label="Enter block"]; - 180 [label="Access variable R|/x|"]; - 181 [label="Function call: R|/x|.R|/A.foo|()"]; - 182 [label="Exit block"]; - } - 183 [label="Exit when branch result"]; - subgraph cluster_57 { - color=blue - 184 [label="Enter when branch condition else"]; - 185 [label="Exit when branch condition"]; - } - subgraph cluster_58 { - color=blue - 186 [label="Enter block"]; - 187 [label="Exit block"]; - } - 188 [label="Exit when branch result"]; - 189 [label="Exit when"]; - } - 190 [label="Exit block"]; - } - 191 [label="Exit function test_7" style="filled" fillcolor=red]; - } - + 166 -> {167}; 167 -> {168}; 168 -> {169}; 169 -> {170}; 170 -> {171}; - 171 -> {172}; + + subgraph cluster_51 { + color=red + 172 [label="Enter function test_7" style="filled" fillcolor=red]; + subgraph cluster_52 { + color=blue + 173 [label="Enter block"]; + subgraph cluster_53 { + color=blue + 174 [label="Enter when"]; + subgraph cluster_54 { + color=blue + 175 [label="Enter when branch condition "]; + subgraph cluster_55 { + color=blue + 176 [label="Enter &&"]; + 177 [label="Access variable R|/x|"]; + 178 [label="Type operator: x is A"]; + 179 [label="Exit left part of &&"]; + 180 [label="Enter right part of &&"]; + 181 [label="Access variable R|/x|"]; + 182 [label="Function call: R|/x|.R|/A.bool|()"]; + 183 [label="Exit &&"]; + } + 184 [label="Exit when branch condition"]; + } + subgraph cluster_56 { + color=blue + 185 [label="Enter block"]; + 186 [label="Access variable R|/x|"]; + 187 [label="Function call: R|/x|.R|/A.foo|()"]; + 188 [label="Exit block"]; + } + 189 [label="Exit when branch result"]; + subgraph cluster_57 { + color=blue + 190 [label="Enter when branch condition else"]; + 191 [label="Exit when branch condition"]; + } + subgraph cluster_58 { + color=blue + 192 [label="Enter block"]; + 193 [label="Exit block"]; + } + 194 [label="Exit when branch result"]; + 195 [label="Exit when"]; + } + 196 [label="Exit block"]; + } + 197 [label="Exit function test_7" style="filled" fillcolor=red]; + } + 172 -> {173}; - 173 -> {177 174}; + 173 -> {174}; 174 -> {175}; 175 -> {176}; 176 -> {177}; 177 -> {178}; - 178 -> {179 184}; - 179 -> {180}; + 178 -> {179}; + 179 -> {183 180}; 180 -> {181}; 181 -> {182}; 182 -> {183}; - 183 -> {189}; - 184 -> {185}; + 183 -> {184}; + 184 -> {185 190}; 185 -> {186}; 186 -> {187}; 187 -> {188}; 188 -> {189}; - 189 -> {190}; + 189 -> {195}; 190 -> {191}; + 191 -> {192}; + 192 -> {193}; + 193 -> {194}; + 194 -> {195}; + 195 -> {196}; + 196 -> {197}; } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/casts.dot b/compiler/fir/resolve/testData/resolve/smartcasts/casts.dot index 16f458c7ef2..d89c4742ca3 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/casts.dot +++ b/compiler/fir/resolve/testData/resolve/smartcasts/casts.dot @@ -109,120 +109,123 @@ digraph casts_kt { 34 [label="Enter &&"]; 35 [label="Access variable R|/b|"]; 36 [label="Exit left part of &&"]; - 37 [label="Access variable R|/x|"]; - 38 [label="Type operator: x as Boolean"]; - 39 [label="Exit &&"]; + 37 [label="Enter right part of &&"]; + 38 [label="Access variable R|/x|"]; + 39 [label="Type operator: x as Boolean"]; + 40 [label="Exit &&"]; } - 40 [label="Exit when branch condition"]; + 41 [label="Exit when branch condition"]; } subgraph cluster_14 { color=blue - 41 [label="Enter block"]; - 42 [label="Access variable R|/x|"]; - 43 [label="Function call: R|/x|.R|kotlin/Boolean.not|()"]; - 44 [label="Exit block"]; + 42 [label="Enter block"]; + 43 [label="Access variable R|/x|"]; + 44 [label="Function call: R|/x|.R|kotlin/Boolean.not|()"]; + 45 [label="Exit block"]; } - 45 [label="Exit when branch result"]; + 46 [label="Exit when branch result"]; subgraph cluster_15 { color=blue - 46 [label="Enter when branch condition else"]; - 47 [label="Exit when branch condition"]; + 47 [label="Enter when branch condition else"]; + 48 [label="Exit when branch condition"]; } subgraph cluster_16 { color=blue - 48 [label="Enter block"]; - 49 [label="Exit block"]; + 49 [label="Enter block"]; + 50 [label="Exit block"]; } - 50 [label="Exit when branch result"]; - 51 [label="Exit when"]; + 51 [label="Exit when branch result"]; + 52 [label="Exit when"]; } - 52 [label="Access variable R|/x|"]; - 53 [label="Function call: R|/x|.#()"]; + 53 [label="Access variable R|/x|"]; + 54 [label="Function call: R|/x|.#()"]; subgraph cluster_17 { color=blue - 54 [label="Enter when"]; + 55 [label="Enter when"]; subgraph cluster_18 { color=blue - 55 [label="Enter when branch condition "]; + 56 [label="Enter when branch condition "]; subgraph cluster_19 { color=blue - 56 [label="Enter &&"]; - 57 [label="Access variable R|/b|"]; - 58 [label="Exit left part of &&"]; - 59 [label="Access variable R|/x|"]; - 60 [label="Type operator: x as Boolean"]; - 61 [label="Const: Boolean(true)"]; - 62 [label="Operator =="]; - 63 [label="Exit &&"]; + 57 [label="Enter &&"]; + 58 [label="Access variable R|/b|"]; + 59 [label="Exit left part of &&"]; + 60 [label="Enter right part of &&"]; + 61 [label="Access variable R|/x|"]; + 62 [label="Type operator: x as Boolean"]; + 63 [label="Const: Boolean(true)"]; + 64 [label="Operator =="]; + 65 [label="Exit &&"]; } - 64 [label="Exit when branch condition"]; + 66 [label="Exit when branch condition"]; } subgraph cluster_20 { color=blue - 65 [label="Enter block"]; - 66 [label="Access variable R|/x|"]; - 67 [label="Function call: R|/x|.R|kotlin/Boolean.not|()"]; - 68 [label="Exit block"]; + 67 [label="Enter block"]; + 68 [label="Access variable R|/x|"]; + 69 [label="Function call: R|/x|.R|kotlin/Boolean.not|()"]; + 70 [label="Exit block"]; } - 69 [label="Exit when branch result"]; + 71 [label="Exit when branch result"]; subgraph cluster_21 { color=blue - 70 [label="Enter when branch condition else"]; - 71 [label="Exit when branch condition"]; + 72 [label="Enter when branch condition else"]; + 73 [label="Exit when branch condition"]; } subgraph cluster_22 { color=blue - 72 [label="Enter block"]; - 73 [label="Exit block"]; + 74 [label="Enter block"]; + 75 [label="Exit block"]; } - 74 [label="Exit when branch result"]; - 75 [label="Exit when"]; + 76 [label="Exit when branch result"]; + 77 [label="Exit when"]; } - 76 [label="Access variable R|/x|"]; - 77 [label="Function call: R|/x|.#()"]; + 78 [label="Access variable R|/x|"]; + 79 [label="Function call: R|/x|.#()"]; subgraph cluster_23 { color=blue - 78 [label="Enter when"]; + 80 [label="Enter when"]; subgraph cluster_24 { color=blue - 79 [label="Enter when branch condition "]; + 81 [label="Enter when branch condition "]; subgraph cluster_25 { color=blue - 80 [label="Enter ||"]; - 81 [label="Access variable R|/b|"]; - 82 [label="Exit left part of ||"]; - 83 [label="Access variable R|/x|"]; - 84 [label="Type operator: x as Boolean"]; - 85 [label="Exit ||"]; + 82 [label="Enter ||"]; + 83 [label="Access variable R|/b|"]; + 84 [label="Exit left part of ||"]; + 85 [label="Enter right part of ||"]; + 86 [label="Access variable R|/x|"]; + 87 [label="Type operator: x as Boolean"]; + 88 [label="Exit ||"]; } - 86 [label="Exit when branch condition"]; + 89 [label="Exit when branch condition"]; } subgraph cluster_26 { color=blue - 87 [label="Enter block"]; - 88 [label="Access variable R|/x|"]; - 89 [label="Function call: R|/x|.#()"]; - 90 [label="Exit block"]; + 90 [label="Enter block"]; + 91 [label="Access variable R|/x|"]; + 92 [label="Function call: R|/x|.#()"]; + 93 [label="Exit block"]; } - 91 [label="Exit when branch result"]; + 94 [label="Exit when branch result"]; subgraph cluster_27 { color=blue - 92 [label="Enter when branch condition else"]; - 93 [label="Exit when branch condition"]; + 95 [label="Enter when branch condition else"]; + 96 [label="Exit when branch condition"]; } subgraph cluster_28 { color=blue - 94 [label="Enter block"]; - 95 [label="Exit block"]; + 97 [label="Enter block"]; + 98 [label="Exit block"]; } - 96 [label="Exit when branch result"]; - 97 [label="Exit when"]; + 99 [label="Exit when branch result"]; + 100 [label="Exit when"]; } - 98 [label="Access variable R|/x|"]; - 99 [label="Function call: R|/x|.#()"]; - 100 [label="Exit block"]; + 101 [label="Access variable R|/x|"]; + 102 [label="Function call: R|/x|.#()"]; + 103 [label="Exit block"]; } - 101 [label="Exit function test_3" style="filled" fillcolor=red]; + 104 [label="Exit function test_3" style="filled" fillcolor=red]; } 30 -> {31}; @@ -230,18 +233,18 @@ digraph casts_kt { 32 -> {33}; 33 -> {34}; 34 -> {35}; - 35 -> {39 36}; - 36 -> {37}; + 35 -> {36}; + 36 -> {40 37}; 37 -> {38}; 38 -> {39}; 39 -> {40}; - 40 -> {41 46}; - 41 -> {42}; + 40 -> {41}; + 41 -> {42 47}; 42 -> {43}; 43 -> {44}; 44 -> {45}; - 45 -> {51}; - 46 -> {47}; + 45 -> {46}; + 46 -> {52}; 47 -> {48}; 48 -> {49}; 49 -> {50}; @@ -252,21 +255,21 @@ digraph casts_kt { 54 -> {55}; 55 -> {56}; 56 -> {57}; - 57 -> {63 58}; + 57 -> {58}; 58 -> {59}; - 59 -> {60}; + 59 -> {65 60}; 60 -> {61}; 61 -> {62}; 62 -> {63}; 63 -> {64}; - 64 -> {65 70}; + 64 -> {65}; 65 -> {66}; - 66 -> {67}; + 66 -> {67 72}; 67 -> {68}; 68 -> {69}; - 69 -> {75}; + 69 -> {70}; 70 -> {71}; - 71 -> {72}; + 71 -> {77}; 72 -> {73}; 73 -> {74}; 74 -> {75}; @@ -276,129 +279,129 @@ digraph casts_kt { 78 -> {79}; 79 -> {80}; 80 -> {81}; - 81 -> {85 82}; + 81 -> {82}; 82 -> {83}; 83 -> {84}; - 84 -> {85}; + 84 -> {88 85}; 85 -> {86}; - 86 -> {87 92}; + 86 -> {87}; 87 -> {88}; 88 -> {89}; - 89 -> {90}; + 89 -> {90 95}; 90 -> {91}; - 91 -> {97}; + 91 -> {92}; 92 -> {93}; 93 -> {94}; - 94 -> {95}; + 94 -> {100}; 95 -> {96}; 96 -> {97}; 97 -> {98}; 98 -> {99}; 99 -> {100}; 100 -> {101}; + 101 -> {102}; + 102 -> {103}; + 103 -> {104}; subgraph cluster_29 { color=red - 102 [label="Enter function test_4" style="filled" fillcolor=red]; + 105 [label="Enter function test_4" style="filled" fillcolor=red]; subgraph cluster_30 { color=blue - 103 [label="Enter block"]; + 106 [label="Enter block"]; subgraph cluster_31 { color=blue - 104 [label="Enter when"]; + 107 [label="Enter when"]; subgraph cluster_32 { color=blue - 105 [label="Enter when branch condition "]; - 106 [label="Access variable R|/b|"]; - 107 [label="Type operator: b as? Boolean"]; - 108 [label="Const: Null(null)"]; - 109 [label="Operator !="]; - 110 [label="Exit when branch condition"]; + 108 [label="Enter when branch condition "]; + 109 [label="Access variable R|/b|"]; + 110 [label="Type operator: b as? Boolean"]; + 111 [label="Const: Null(null)"]; + 112 [label="Operator !="]; + 113 [label="Exit when branch condition"]; } subgraph cluster_33 { color=blue - 111 [label="Enter block"]; - 112 [label="Access variable R|/b|"]; - 113 [label="Function call: R|/b|.R|kotlin/Boolean.not|()"]; - 114 [label="Exit block"]; + 114 [label="Enter block"]; + 115 [label="Access variable R|/b|"]; + 116 [label="Function call: R|/b|.R|kotlin/Boolean.not|()"]; + 117 [label="Exit block"]; } - 115 [label="Exit when branch result"]; + 118 [label="Exit when branch result"]; subgraph cluster_34 { color=blue - 116 [label="Enter when branch condition else"]; - 117 [label="Exit when branch condition"]; + 119 [label="Enter when branch condition else"]; + 120 [label="Exit when branch condition"]; } subgraph cluster_35 { color=blue - 118 [label="Enter block"]; - 119 [label="Access variable R|/b|"]; - 120 [label="Function call: R|/b|.#()"]; - 121 [label="Exit block"]; + 121 [label="Enter block"]; + 122 [label="Access variable R|/b|"]; + 123 [label="Function call: R|/b|.#()"]; + 124 [label="Exit block"]; } - 122 [label="Exit when branch result"]; - 123 [label="Exit when"]; + 125 [label="Exit when branch result"]; + 126 [label="Exit when"]; } - 124 [label="Access variable R|/b|"]; - 125 [label="Function call: R|/b|.#()"]; + 127 [label="Access variable R|/b|"]; + 128 [label="Function call: R|/b|.#()"]; subgraph cluster_36 { color=blue - 126 [label="Enter when"]; + 129 [label="Enter when"]; subgraph cluster_37 { color=blue - 127 [label="Enter when branch condition "]; - 128 [label="Access variable R|/b|"]; - 129 [label="Type operator: b as? Boolean"]; - 130 [label="Const: Null(null)"]; - 131 [label="Operator =="]; - 132 [label="Exit when branch condition"]; + 130 [label="Enter when branch condition "]; + 131 [label="Access variable R|/b|"]; + 132 [label="Type operator: b as? Boolean"]; + 133 [label="Const: Null(null)"]; + 134 [label="Operator =="]; + 135 [label="Exit when branch condition"]; } subgraph cluster_38 { color=blue - 133 [label="Enter block"]; - 134 [label="Access variable R|/b|"]; - 135 [label="Function call: R|/b|.#()"]; - 136 [label="Exit block"]; + 136 [label="Enter block"]; + 137 [label="Access variable R|/b|"]; + 138 [label="Function call: R|/b|.#()"]; + 139 [label="Exit block"]; } - 137 [label="Exit when branch result"]; + 140 [label="Exit when branch result"]; subgraph cluster_39 { color=blue - 138 [label="Enter when branch condition else"]; - 139 [label="Exit when branch condition"]; + 141 [label="Enter when branch condition else"]; + 142 [label="Exit when branch condition"]; } subgraph cluster_40 { color=blue - 140 [label="Enter block"]; - 141 [label="Access variable R|/b|"]; - 142 [label="Function call: R|/b|.R|kotlin/Boolean.not|()"]; - 143 [label="Exit block"]; + 143 [label="Enter block"]; + 144 [label="Access variable R|/b|"]; + 145 [label="Function call: R|/b|.R|kotlin/Boolean.not|()"]; + 146 [label="Exit block"]; } - 144 [label="Exit when branch result"]; - 145 [label="Exit when"]; + 147 [label="Exit when branch result"]; + 148 [label="Exit when"]; } - 146 [label="Access variable R|/b|"]; - 147 [label="Function call: R|/b|.#()"]; - 148 [label="Exit block"]; + 149 [label="Access variable R|/b|"]; + 150 [label="Function call: R|/b|.#()"]; + 151 [label="Exit block"]; } - 149 [label="Exit function test_4" style="filled" fillcolor=red]; + 152 [label="Exit function test_4" style="filled" fillcolor=red]; } - 102 -> {103}; - 103 -> {104}; - 104 -> {105}; 105 -> {106}; 106 -> {107}; 107 -> {108}; 108 -> {109}; 109 -> {110}; - 110 -> {111 116}; + 110 -> {111}; 111 -> {112}; 112 -> {113}; - 113 -> {114}; + 113 -> {114 119}; 114 -> {115}; - 115 -> {123}; + 115 -> {116}; 116 -> {117}; 117 -> {118}; - 118 -> {119}; + 118 -> {126}; 119 -> {120}; 120 -> {121}; 121 -> {122}; @@ -412,15 +415,15 @@ digraph casts_kt { 129 -> {130}; 130 -> {131}; 131 -> {132}; - 132 -> {133 138}; + 132 -> {133}; 133 -> {134}; 134 -> {135}; - 135 -> {136}; + 135 -> {136 141}; 136 -> {137}; - 137 -> {145}; + 137 -> {138}; 138 -> {139}; 139 -> {140}; - 140 -> {141}; + 140 -> {148}; 141 -> {142}; 142 -> {143}; 143 -> {144}; @@ -429,5 +432,8 @@ digraph casts_kt { 146 -> {147}; 147 -> {148}; 148 -> {149}; + 149 -> {150}; + 150 -> {151}; + 151 -> {152}; }