From cc9c5b9e3c6aa85244c4af8c9fcb4536580bbb7e Mon Sep 17 00:00:00 2001 From: Oleg Ivanov Date: Thu, 30 Jul 2020 17:06:30 +0300 Subject: [PATCH] [FIR] Add CFG nodes, add multiple subGraphs for CFGOwner --- .../resolve/cfg/annotatedLocalClass.dot | 18 +- .../testData/resolve/cfg/defaultArguments.dot | 3 + .../resolve/cfg/flowFromInplaceLambda.dot | 11 + .../testData/resolve/cfg/initBlock.dot | 148 ++-- .../resolve/cfg/initBlockAndInPlaceLambda.dot | 134 ++-- .../cfg/innerClassInAnonymousObject.dot | 12 +- .../inplaceLambdaInControlFlowExpressions.dot | 3 + .../testData/resolve/cfg/jumps.dot | 1 + .../resolve/cfg/lambdaAsReturnOfLambda.dot | 2 + .../resolve/cfg/lambdaReturningObject.dot | 1 + .../testData/resolve/cfg/lambdas.dot | 4 + .../resolve/cfg/localClassesWithImplicit.dot | 34 +- .../cfg/postponedLambdaInConstructor.dot | 159 ++-- .../testData/resolve/cfg/postponedLambdas.dot | 1 + .../resolve/cfg/propertiesAndInitBlocks.dot | 387 ++++----- .../resolve/cfg/returnValuesFromLambda.dot | 3 + .../problems/secondaryConstructorCfg.dot | 229 +++--- .../boundSmartcasts/boundSmartcasts.dot | 341 ++++---- .../boundSmartcasts/functionCallBound.dot | 239 +++--- .../smartcasts/controlStructures/returns.dot | 1 + .../smartcasts/lambdas/inPlaceLambdas.dot | 3 + .../smartcasts/lambdas/lambdaInWhenBranch.dot | 399 +++++----- .../receivers/implicitReceivers.dot | 3 + .../smartcasts/safeCalls/assignSafeCall.dot | 733 +++++++++--------- .../smartcasts/safeCalls/safeCalls.dot | 2 + .../resolve/smartcasts/smartCastInInit.dot | 81 +- .../resolve/smartcasts/smartcastToNothing.dot | 359 +++++---- .../smartcasts/stability/overridenOpenVal.dot | 255 +++--- .../resolveWithStdlib/complexPostponedCfg.dot | 3 + .../contracts/fromLibrary/callsInPlace.dot | 10 + .../good/callsInPlace/atLeastOnce.dot | 2 + .../good/callsInPlace/atMostOnce.dot | 2 + .../good/callsInPlace/exactlyOnce.dot | 2 + .../fromSource/good/callsInPlace/unknown.dot | 2 + .../delegates/delegateWithAnonymousObject.dot | 295 +++---- .../inference/plusAssignWithLambdaInRhs.dot | 170 ++-- .../initialization/fromLocalMembers.kt | 46 ++ .../initialization/fromLocalMembers.txt | 51 ++ .../smartcasts/tryWithLambdaInside.dot | 2 + ...FirDiagnosticsWithStdlibTestGenerated.java | 18 + .../kotlin/fir/analysis/cfa/CfgTraverser.kt | 6 +- .../analysis/cfa/FirControlFlowAnalyzer.kt | 4 +- .../fir/resolve/dfa/FirDataFlowAnalyzer.kt | 3 +- .../kotlin/fir/resolve/dfa/cfg/CFGNode.kt | 30 +- .../fir/resolve/dfa/cfg/CFGNodeRenderer.kt | 2 + .../dfa/cfg/ControlFlowGraphBuilder.kt | 44 +- .../dfa/cfg/ControlFlowGraphNodeBuilder.kt | 6 + .../dfa/cfg/ControlFlowGraphRenderer.kt | 13 + .../dfa/cfg/ControlFlowGraphVisitor.kt | 10 + .../checkPropertyAccessor.fir.kt | 2 +- .../tests/controlFlowAnalysis/kt2960.fir.kt | 4 +- .../uninitializedInLocalDeclarations.fir.kt | 6 +- 52 files changed, 2359 insertions(+), 1940 deletions(-) create mode 100644 compiler/fir/analysis-tests/testData/resolveWithStdlib/initialization/fromLocalMembers.kt create mode 100644 compiler/fir/analysis-tests/testData/resolveWithStdlib/initialization/fromLocalMembers.txt diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/annotatedLocalClass.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/annotatedLocalClass.dot index 704fe6d4b4f..81c1713aa74 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/annotatedLocalClass.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/annotatedLocalClass.dot @@ -23,17 +23,12 @@ digraph annotatedLocalClass_kt { color=red 5 [label="Enter function foo" style="filled" fillcolor=red]; subgraph cluster_3 { - color=blue - 23 [label="Enter class Local" style="filled" fillcolor=red]; - 24 [label="Exit class Local" style="filled" fillcolor=red]; - } - subgraph cluster_4 { color=blue 6 [label="Enter block"]; - subgraph cluster_5 { + subgraph cluster_4 { color=blue 7 [label="Enter when"]; - subgraph cluster_6 { + subgraph cluster_5 { color=blue 8 [label="Enter when branch condition "]; 9 [label="Access variable R|/b|"]; @@ -41,7 +36,7 @@ digraph annotatedLocalClass_kt { } 11 [label="Synthetic else branch"]; 12 [label="Enter when branch result"]; - subgraph cluster_7 { + subgraph cluster_6 { color=blue 13 [label="Enter block"]; 14 [label="Jump: ^foo Unit"]; @@ -55,6 +50,11 @@ digraph annotatedLocalClass_kt { 20 [label="Function call: R|/bar|()"]; 21 [label="Exit block"]; } + subgraph cluster_7 { + color=blue + 23 [label="Enter class Local" style="filled" fillcolor=red]; + 24 [label="Exit class Local" style="filled" fillcolor=red]; + } 22 [label="Exit function foo" style="filled" fillcolor=red]; } 5 -> {6}; @@ -74,6 +74,8 @@ digraph annotatedLocalClass_kt { 18 -> {19}; 18 -> {25} [color=red]; 19 -> {20}; + 19 -> {25 23} [color=green]; + 19 -> {25 23} [style=dashed]; 20 -> {21}; 21 -> {22}; 23 -> {24} [color=green]; diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/defaultArguments.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/defaultArguments.dot index 0c9eb5c8288..6d25387b933 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/defaultArguments.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/defaultArguments.dot @@ -67,11 +67,14 @@ digraph defaultArguments_kt { 9 -> {10}; 10 -> {11}; 12 -> {13}; + 12 -> {12} [style=dashed]; 13 -> {14}; 14 -> {15}; 16 -> {17}; + 16 -> {16} [style=dashed]; 17 -> {22}; 17 -> {19} [color=red]; + 17 -> {22} [style=dashed]; 18 -> {20} [color=red]; 19 -> {20} [color=green]; 20 -> {21}; diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/flowFromInplaceLambda.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/flowFromInplaceLambda.dot index 8e15644d748..2a111b57af8 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/flowFromInplaceLambda.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/flowFromInplaceLambda.dot @@ -139,6 +139,7 @@ digraph flowFromInplaceLambda_kt { 36 -> {37}; 37 -> {45}; 37 -> {39} [color=red]; + 37 -> {45} [style=dashed]; 38 -> {40} [color=red]; 39 -> {40} [color=green]; 40 -> {41}; @@ -215,6 +216,7 @@ digraph flowFromInplaceLambda_kt { 52 -> {53}; 53 -> {74}; 53 -> {54} [color=red]; + 53 -> {74} [style=dashed]; 54 -> {55}; 55 -> {56}; 56 -> {57}; @@ -223,6 +225,7 @@ digraph flowFromInplaceLambda_kt { 59 -> {60}; 60 -> {82}; 60 -> {61} [color=red]; + 60 -> {82} [style=dashed]; 61 -> {62}; 62 -> {63}; 63 -> {64}; @@ -317,11 +320,13 @@ digraph flowFromInplaceLambda_kt { 92 -> {93}; 93 -> {111}; 93 -> {94} [color=red]; + 93 -> {111} [style=dashed]; 94 -> {95}; 95 -> {96}; 96 -> {97}; 97 -> {120}; 97 -> {98} [color=red]; + 97 -> {120} [style=dashed]; 98 -> {99}; 99 -> {100}; 100 -> {101}; @@ -416,12 +421,14 @@ digraph flowFromInplaceLambda_kt { 131 -> {132}; 132 -> {133}; 133 -> {134 152}; + 133 -> {152} [style=dashed]; 134 -> {135}; 135 -> {136}; 136 -> {137}; 137 -> {138}; 138 -> {139}; 139 -> {140 160}; + 139 -> {160} [style=dashed]; 140 -> {141}; 141 -> {142}; 142 -> {143}; @@ -496,10 +503,12 @@ digraph flowFromInplaceLambda_kt { 170 -> {171}; 171 -> {184}; 171 -> {172} [color=red]; + 171 -> {184} [style=dashed]; 172 -> {173}; 173 -> {174}; 174 -> {189}; 174 -> {175} [color=red]; + 174 -> {189} [style=dashed]; 175 -> {176}; 176 -> {177}; 177 -> {178}; @@ -563,6 +572,7 @@ digraph flowFromInplaceLambda_kt { 194 -> {195}; 195 -> {196}; 196 -> {197 203}; + 196 -> {203} [style=dashed]; 197 -> {198}; 198 -> {199}; 199 -> {200}; @@ -572,6 +582,7 @@ digraph flowFromInplaceLambda_kt { 204 -> {205}; 205 -> {210}; 205 -> {206} [color=red]; + 205 -> {210} [style=dashed]; 206 -> {207}; 207 -> {208}; 208 -> {209}; diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/initBlock.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/initBlock.dot index 93036524e26..445e69cf5b6 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/initBlock.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/initBlock.dot @@ -8,78 +8,92 @@ digraph initBlock_kt { 0 [label="Enter class Foo" style="filled" fillcolor=red]; subgraph cluster_1 { color=blue - 2 [label="Enter init block" style="filled" fillcolor=red]; - subgraph cluster_2 { - color=blue - 3 [label="Enter block"]; - 4 [label="Const: Int(1)"]; - 5 [label="Variable declaration: lval x: R|kotlin/Int|"]; - 6 [label="Exit block"]; - } - 7 [label="Exit init block" style="filled" fillcolor=red]; + 1 [label="Part of class initialization"]; + 2 [label="Exit class Foo" style="filled" fillcolor=red]; } - 1 [label="Exit class Foo" style="filled" fillcolor=red]; - } - 0 -> {2} [color=green]; - 2 -> {3}; - 3 -> {4}; - 4 -> {5}; - 5 -> {6}; - 6 -> {7}; - 7 -> {1} [color=green]; + 0 -> {1} [color=green]; + 1 -> {2} [style=dotted]; + 1 -> {6} [color=green]; + 1 -> {6} [style=dashed]; - subgraph cluster_3 { - color=red - 8 [label="Enter function " style="filled" fillcolor=red]; - 9 [label="Delegated constructor call: super()"]; - 10 [label="Exit function " style="filled" fillcolor=red]; - } - 8 -> {9}; - 9 -> {10}; + subgraph cluster_2 { + color=red + 3 [label="Enter function " style="filled" fillcolor=red]; + 4 [label="Delegated constructor call: super()"]; + 5 [label="Exit function " style="filled" fillcolor=red]; + } + 3 -> {4}; + 4 -> {5}; + + subgraph cluster_3 { + color=red + 6 [label="Enter init block" style="filled" fillcolor=red]; + subgraph cluster_4 { + color=blue + 7 [label="Enter block"]; + 8 [label="Const: Int(1)"]; + 9 [label="Variable declaration: lval x: R|kotlin/Int|"]; + 10 [label="Exit block"]; + } + 11 [label="Exit init block" style="filled" fillcolor=red]; + } + 6 -> {7}; + 7 -> {8}; + 8 -> {9}; + 9 -> {10}; + 10 -> {11}; + 11 -> {2} [color=green]; - subgraph cluster_4 { - color=red - 11 [label="Enter class Bar" style="filled" fillcolor=red]; subgraph cluster_5 { - color=blue - 13 [label="Enter init block" style="filled" fillcolor=red]; + color=red + 12 [label="Enter class Bar" style="filled" fillcolor=red]; subgraph cluster_6 { color=blue - 14 [label="Enter block"]; - 15 [label="Const: Int(1)"]; - 16 [label="Variable declaration: lval x: R|kotlin/Int|"]; - 17 [label="Function call: R|java/lang/Exception.Exception|()"]; - 18 [label="Throw: throw R|java/lang/Exception.Exception|()"]; - 19 [label="Stub" style="filled" fillcolor=gray]; - 20 [label="Const: Int(2)" style="filled" fillcolor=gray]; - 21 [label="Variable declaration: lval y: R|kotlin/Int|" style="filled" fillcolor=gray]; - 22 [label="Exit block" style="filled" fillcolor=gray]; + 13 [label="Part of class initialization"]; + 14 [label="Exit class Bar" style="filled" fillcolor=red]; } - 23 [label="Exit init block" style="filled" fillcolor=red]; + 12 -> {13} [color=green]; + 13 -> {14} [style=dotted]; + 13 -> {18} [color=green]; + 13 -> {18} [style=dashed]; + + subgraph cluster_7 { + color=red + 15 [label="Enter function " style="filled" fillcolor=red]; + 16 [label="Delegated constructor call: super()"]; + 17 [label="Exit function " style="filled" fillcolor=red]; + } + 15 -> {16}; + 16 -> {17}; + + subgraph cluster_8 { + color=red + 18 [label="Enter init block" style="filled" fillcolor=red]; + subgraph cluster_9 { + color=blue + 19 [label="Enter block"]; + 20 [label="Const: Int(1)"]; + 21 [label="Variable declaration: lval x: R|kotlin/Int|"]; + 22 [label="Function call: R|java/lang/Exception.Exception|()"]; + 23 [label="Throw: throw R|java/lang/Exception.Exception|()"]; + 24 [label="Stub" style="filled" fillcolor=gray]; + 25 [label="Const: Int(2)" style="filled" fillcolor=gray]; + 26 [label="Variable declaration: lval y: R|kotlin/Int|" style="filled" fillcolor=gray]; + 27 [label="Exit block" style="filled" fillcolor=gray]; + } + 28 [label="Exit init block" style="filled" fillcolor=red]; + } + 18 -> {19}; + 19 -> {20}; + 20 -> {21}; + 21 -> {22}; + 22 -> {23}; + 23 -> {28}; + 23 -> {24} [style=dotted]; + 24 -> {25} [style=dotted]; + 25 -> {26} [style=dotted]; + 26 -> {27} [style=dotted]; + 27 -> {28} [style=dotted]; + 28 -> {14} [color=green]; + } - 12 [label="Exit class Bar" style="filled" fillcolor=red]; - } - 11 -> {13} [color=green]; - 13 -> {14}; - 14 -> {15}; - 15 -> {16}; - 16 -> {17}; - 17 -> {18}; - 18 -> {23}; - 18 -> {19} [style=dotted]; - 19 -> {20} [style=dotted]; - 20 -> {21} [style=dotted]; - 21 -> {22} [style=dotted]; - 22 -> {23} [style=dotted]; - 23 -> {12} [color=green]; - - subgraph cluster_7 { - color=red - 24 [label="Enter function " style="filled" fillcolor=red]; - 25 [label="Delegated constructor call: super()"]; - 26 [label="Exit function " style="filled" fillcolor=red]; - } - 24 -> {25}; - 25 -> {26}; - -} diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/initBlockAndInPlaceLambda.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/initBlockAndInPlaceLambda.dot index 939bee6eb87..3a6c27361a7 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/initBlockAndInPlaceLambda.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/initBlockAndInPlaceLambda.dot @@ -29,69 +29,77 @@ digraph initBlockAndInPlaceLambda_kt { 6 [label="Enter class C" style="filled" fillcolor=red]; subgraph cluster_4 { color=blue - 8 [label="Enter init block" style="filled" fillcolor=red]; - subgraph cluster_5 { - color=blue - 9 [label="Enter block"]; - 10 [label="Access variable R|/a|"]; - 11 [label="Access variable R|/A.b|"]; - 12 [label="Enter safe call"]; - 13 [label="Postponed enter to lambda"]; - subgraph cluster_6 { - color=blue - 21 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; - subgraph cluster_7 { - color=blue - 22 [label="Enter block"]; - 23 [label="Access variable R|/a|"]; - 24 [label="Access variable R|/it|"]; - 25 [label="Function call: R|/C.C|(...)"]; - 26 [label="Exit block"]; - } - 27 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; - } - 14 [label="Call arguments union" style="filled" fillcolor=yellow]; - 15 [label="Postponed exit from lambda"]; - 16 [label="Function call: $subj$.R|kotlin/let|(...)"]; - 17 [label="Exit safe call"]; - 18 [label="Variable declaration: lval c: R|C?|"]; - 19 [label="Exit block"]; - } - 20 [label="Exit init block" style="filled" fillcolor=red]; + 7 [label="Part of class initialization"]; + 8 [label="Exit class C" style="filled" fillcolor=red]; } - 7 [label="Exit class C" style="filled" fillcolor=red]; - } - 6 -> {8} [color=green]; - 8 -> {9}; - 9 -> {10}; - 10 -> {11}; - 11 -> {12 17}; - 12 -> {13}; - 13 -> {21}; - 13 -> {15} [color=red]; - 14 -> {16} [color=red]; - 15 -> {16} [color=green]; - 16 -> {17}; - 17 -> {18}; - 18 -> {19}; - 19 -> {20}; - 20 -> {7} [color=green]; - 21 -> {22}; - 22 -> {23}; - 23 -> {24}; - 24 -> {25}; - 25 -> {26}; - 26 -> {27}; - 27 -> {14} [color=red]; - 27 -> {15} [color=green]; + 6 -> {7} [color=green]; + 7 -> {8} [style=dotted]; + 7 -> {12} [color=green]; + 7 -> {12} [style=dashed]; - subgraph cluster_8 { - color=red - 28 [label="Enter function " style="filled" fillcolor=red]; - 29 [label="Delegated constructor call: super()"]; - 30 [label="Exit function " style="filled" fillcolor=red]; - } - 28 -> {29}; - 29 -> {30}; + subgraph cluster_5 { + color=red + 9 [label="Enter function " style="filled" fillcolor=red]; + 10 [label="Delegated constructor call: super()"]; + 11 [label="Exit function " style="filled" fillcolor=red]; + } + 9 -> {10}; + 10 -> {11}; -} + subgraph cluster_6 { + color=red + 12 [label="Enter init block" style="filled" fillcolor=red]; + subgraph cluster_7 { + color=blue + 13 [label="Enter block"]; + 14 [label="Access variable R|/a|"]; + 15 [label="Access variable R|/A.b|"]; + 16 [label="Enter safe call"]; + 17 [label="Postponed enter to lambda"]; + subgraph cluster_8 { + color=blue + 25 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + subgraph cluster_9 { + color=blue + 26 [label="Enter block"]; + 27 [label="Access variable R|/a|"]; + 28 [label="Access variable R|/it|"]; + 29 [label="Function call: R|/C.C|(...)"]; + 30 [label="Exit block"]; + } + 31 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + } + 18 [label="Call arguments union" style="filled" fillcolor=yellow]; + 19 [label="Postponed exit from lambda"]; + 20 [label="Function call: $subj$.R|kotlin/let|(...)"]; + 21 [label="Exit safe call"]; + 22 [label="Variable declaration: lval c: R|C?|"]; + 23 [label="Exit block"]; + } + 24 [label="Exit init block" style="filled" fillcolor=red]; + } + 12 -> {13}; + 13 -> {14}; + 14 -> {15}; + 15 -> {16 21}; + 16 -> {17}; + 17 -> {25}; + 17 -> {19} [color=red]; + 17 -> {25} [style=dashed]; + 18 -> {20} [color=red]; + 19 -> {20} [color=green]; + 20 -> {21}; + 21 -> {22}; + 22 -> {23}; + 23 -> {24}; + 24 -> {8} [color=green]; + 25 -> {26}; + 26 -> {27}; + 27 -> {28}; + 28 -> {29}; + 29 -> {30}; + 30 -> {31}; + 31 -> {18} [color=red]; + 31 -> {19} [color=green]; + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/innerClassInAnonymousObject.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/innerClassInAnonymousObject.dot index 36ed09e0ffa..1b7bac4a57c 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/innerClassInAnonymousObject.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/innerClassInAnonymousObject.dot @@ -52,17 +52,19 @@ digraph innerClassInAnonymousObject_kt { subgraph cluster_6 { color=red 16 [label="Enter property" style="filled" fillcolor=red]; - subgraph cluster_7 { - color=blue - 12 [label="Enter class " style="filled" fillcolor=red]; - 13 [label="Exit class " style="filled" fillcolor=red]; - } 17 [label="Exit anonymous object"]; 18 [label="Exit property" style="filled" fillcolor=red]; } + subgraph cluster_7 { + color=blue + 12 [label="Enter class " style="filled" fillcolor=red]; + 13 [label="Exit class " style="filled" fillcolor=red]; + } 16 -> {17}; 16 -> {0 5 8} [color=red]; 17 -> {18}; + 17 -> {0 12} [color=green]; + 17 -> {0 12} [style=dashed]; 12 -> {13} [color=green]; } diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/inplaceLambdaInControlFlowExpressions.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/inplaceLambdaInControlFlowExpressions.dot index 9287b64249c..5ded06dbbe7 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/inplaceLambdaInControlFlowExpressions.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/inplaceLambdaInControlFlowExpressions.dot @@ -99,6 +99,7 @@ digraph inplaceLambdaInControlFlowExpressions_kt { 22 -> {23}; 23 -> {32}; 23 -> {24} [color=red]; + 23 -> {32} [style=dashed]; 24 -> {25}; 25 -> {26}; 26 -> {27}; @@ -171,6 +172,7 @@ digraph inplaceLambdaInControlFlowExpressions_kt { 41 -> {42}; 42 -> {57}; 42 -> {43} [color=red]; + 42 -> {57} [style=dashed]; 43 -> {44}; 44 -> {45}; 45 -> {46}; @@ -222,6 +224,7 @@ digraph inplaceLambdaInControlFlowExpressions_kt { 63 -> {64}; 64 -> {72}; 64 -> {65} [color=red]; + 64 -> {72} [style=dashed]; 65 -> {66}; 66 -> {67}; 67 -> {68}; diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/jumps.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/jumps.dot index 0a6cb1c2a81..fe27f63007f 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/jumps.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/jumps.dot @@ -397,6 +397,7 @@ digraph jumps_kt { 125 -> {126}; 126 -> {131}; 126 -> {127} [color=red]; + 126 -> {131} [style=dashed]; 127 -> {128}; 128 -> {129}; 129 -> {130}; diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/lambdaAsReturnOfLambda.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/lambdaAsReturnOfLambda.dot index b69222c5a33..57acba80ead 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/lambdaAsReturnOfLambda.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/lambdaAsReturnOfLambda.dot @@ -54,6 +54,7 @@ digraph lambdaAsReturnOfLambda_kt { } 16 -> {17}; 17 -> {18 0}; + 17 -> {0} [style=dashed]; 18 -> {19}; 19 -> {20}; 20 -> {21}; @@ -61,6 +62,7 @@ digraph lambdaAsReturnOfLambda_kt { 0 -> {1}; 1 -> {2}; 2 -> {3 8}; + 2 -> {8} [style=dashed]; 3 -> {4}; 4 -> {7}; 4 -> {5} [style=dotted]; diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/lambdaReturningObject.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/lambdaReturningObject.dot index 1819b901f0f..91aaf50e616 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/lambdaReturningObject.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/lambdaReturningObject.dot @@ -98,6 +98,7 @@ digraph lambdaReturningObject_kt { 21 -> {22}; 22 -> {23}; 23 -> {24 29}; + 23 -> {29} [style=dashed]; 24 -> {25}; 25 -> {26}; 26 -> {27}; diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/lambdas.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/lambdas.dot index f5e63239749..2d4159aa89d 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/lambdas.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/lambdas.dot @@ -76,6 +76,7 @@ digraph lambdas_kt { 14 -> {15}; 15 -> {23}; 15 -> {16} [color=red]; + 15 -> {23} [style=dashed]; 16 -> {17}; 17 -> {18}; 18 -> {19}; @@ -146,6 +147,7 @@ digraph lambdas_kt { 37 -> {38}; 38 -> {39}; 39 -> {40 47}; + 39 -> {47} [style=dashed]; 40 -> {41}; 41 -> {42}; 42 -> {43}; @@ -216,6 +218,7 @@ digraph lambdas_kt { 62 -> {63}; 63 -> {70}; 63 -> {64} [color=red]; + 63 -> {70} [style=dashed]; 64 -> {65}; 65 -> {66}; 66 -> {69}; @@ -267,6 +270,7 @@ digraph lambdas_kt { 78 -> {79}; 79 -> {86}; 79 -> {80} [color=red]; + 79 -> {86} [style=dashed]; 80 -> {81}; 81 -> {82}; 82 -> {85}; diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/localClassesWithImplicit.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/localClassesWithImplicit.dot index e410deaf012..48c18690863 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/localClassesWithImplicit.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/localClassesWithImplicit.dot @@ -28,22 +28,12 @@ digraph localClassesWithImplicit_kt { color=red 7 [label="Enter function test" style="filled" fillcolor=red]; subgraph cluster_3 { - color=blue - 29 [label="Enter class " style="filled" fillcolor=red]; - 30 [label="Exit class " style="filled" fillcolor=red]; - } - subgraph cluster_4 { - color=blue - 27 [label="Enter class A" style="filled" fillcolor=red]; - 28 [label="Exit class A" style="filled" fillcolor=red]; - } - subgraph cluster_5 { color=blue 8 [label="Enter block"]; - subgraph cluster_6 { + subgraph cluster_4 { color=blue 9 [label="Enter when"]; - subgraph cluster_7 { + subgraph cluster_5 { color=blue 10 [label="Enter when branch condition "]; 11 [label="Access variable R|/a|"]; @@ -52,7 +42,7 @@ digraph localClassesWithImplicit_kt { } 14 [label="Synthetic else branch"]; 15 [label="Enter when branch result"]; - subgraph cluster_8 { + subgraph cluster_6 { color=blue 16 [label="Enter block"]; 17 [label="Jump: ^test Unit"]; @@ -67,6 +57,16 @@ digraph localClassesWithImplicit_kt { 24 [label="Variable declaration: lval x: R||"]; 25 [label="Exit block"]; } + subgraph cluster_7 { + color=blue + 29 [label="Enter class " style="filled" fillcolor=red]; + 30 [label="Exit class " style="filled" fillcolor=red]; + } + subgraph cluster_8 { + color=blue + 27 [label="Enter class A" style="filled" fillcolor=red]; + 28 [label="Exit class A" style="filled" fillcolor=red]; + } 26 [label="Exit function test" style="filled" fillcolor=red]; } 7 -> {8}; @@ -88,7 +88,11 @@ digraph localClassesWithImplicit_kt { 21 -> {31 34 69 87} [color=red]; 22 -> {23}; 22 -> {94 97 132 150} [color=red]; + 22 -> {31 34 69 87 27} [color=green]; + 22 -> {31 34 69 87 27} [style=dashed]; 23 -> {24}; + 23 -> {94 97 132 150 29} [color=green]; + 23 -> {94 97 132 150 29} [style=dashed]; 24 -> {25}; 25 -> {26}; 27 -> {28} [color=green]; @@ -182,6 +186,7 @@ digraph localClassesWithImplicit_kt { 35 -> {36}; 36 -> {43}; 36 -> {37} [color=red]; + 36 -> {43} [style=dashed]; 37 -> {38}; 38 -> {39}; 39 -> {42}; @@ -255,6 +260,7 @@ digraph localClassesWithImplicit_kt { 70 -> {71}; 71 -> {78}; 71 -> {72} [color=red]; + 71 -> {78} [style=dashed]; 72 -> {73}; 73 -> {74}; 74 -> {77}; @@ -381,6 +387,7 @@ digraph localClassesWithImplicit_kt { 98 -> {99}; 99 -> {106}; 99 -> {100} [color=red]; + 99 -> {106} [style=dashed]; 100 -> {101}; 101 -> {102}; 102 -> {105}; @@ -454,6 +461,7 @@ digraph localClassesWithImplicit_kt { 133 -> {134}; 134 -> {141}; 134 -> {135} [color=red]; + 134 -> {141} [style=dashed]; 135 -> {136}; 136 -> {137}; 137 -> {140}; diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/postponedLambdaInConstructor.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/postponedLambdaInConstructor.dot index c2b9a97dab5..0d300287df3 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/postponedLambdaInConstructor.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/postponedLambdaInConstructor.dot @@ -24,92 +24,101 @@ digraph postponedLambdaInConstructor_kt { 5 [label="Enter class B" style="filled" fillcolor=red]; subgraph cluster_3 { color=blue - 7 [label="Enter property" style="filled" fillcolor=red]; - 8 [label="Access variable R|/s|"]; - 9 [label="Exit property" style="filled" fillcolor=red]; + 6 [label="Part of class initialization"]; + 7 [label="Exit class B" style="filled" fillcolor=red]; } - 6 [label="Exit class B" style="filled" fillcolor=red]; - } - 5 -> {7} [color=green]; - 7 -> {8}; - 8 -> {9}; - 9 -> {6} [color=green]; + 5 -> {6} [color=green]; + 6 -> {7} [style=dotted]; + 6 -> {29} [color=green]; + 6 -> {29} [style=dashed]; - subgraph cluster_4 { - color=red - 10 [label="Enter function " style="filled" fillcolor=red]; - 11 [label="Access variable R|/s|"]; - 12 [label="Postponed enter to lambda"]; - subgraph cluster_5 { - color=blue - 18 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; - subgraph cluster_6 { + subgraph cluster_4 { + color=red + 8 [label="Enter function " style="filled" fillcolor=red]; + 9 [label="Access variable R|/s|"]; + 10 [label="Postponed enter to lambda"]; + subgraph cluster_5 { color=blue - 19 [label="Enter block"]; - 20 [label="Postponed enter to lambda"]; - subgraph cluster_7 { + 16 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + subgraph cluster_6 { color=blue - 24 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; - subgraph cluster_8 { + 17 [label="Enter block"]; + 18 [label="Postponed enter to lambda"]; + subgraph cluster_7 { color=blue - 25 [label="Enter block"]; - 26 [label="Access variable R|/it|"]; - 27 [label="Exit block"]; + 22 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + subgraph cluster_8 { + color=blue + 23 [label="Enter block"]; + 24 [label="Access variable R|/it|"]; + 25 [label="Exit block"]; + } + 26 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 28 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 19 [label="Postponed exit from lambda"]; + 20 [label="Exit block"]; } - 21 [label="Postponed exit from lambda"]; - 22 [label="Exit block"]; + 21 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 23 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 11 [label="Postponed exit from lambda"]; + 12 [label="Function call: R|/s|.R|kotlin/let| kotlin/String|>(...)"]; + 13 [label="Call arguments union" style="filled" fillcolor=yellow]; + 14 [label="Delegated constructor call: super(...)"]; + 15 [label="Exit function " style="filled" fillcolor=red]; } - 13 [label="Postponed exit from lambda"]; - 14 [label="Function call: R|/s|.R|kotlin/let| kotlin/String|>(...)"]; - 15 [label="Call arguments union" style="filled" fillcolor=yellow]; - 16 [label="Delegated constructor call: super(...)"]; - 17 [label="Exit function " style="filled" fillcolor=red]; - } - 10 -> {11}; - 11 -> {12}; - 12 -> {18}; - 12 -> {13} [color=red]; - 13 -> {14}; - 14 -> {15}; - 15 -> {16}; - 16 -> {17}; - 18 -> {19}; - 19 -> {20}; - 20 -> {21 24}; - 21 -> {22}; - 22 -> {23}; - 23 -> {15} [color=red]; - 23 -> {13} [color=green]; - 24 -> {25}; - 25 -> {26}; - 26 -> {27}; - 27 -> {28}; + 8 -> {9}; + 9 -> {10}; + 10 -> {16}; + 10 -> {11} [color=red]; + 10 -> {16} [style=dashed]; + 11 -> {12}; + 12 -> {13}; + 13 -> {14}; + 14 -> {15}; + 16 -> {17}; + 17 -> {18}; + 18 -> {19 22}; + 18 -> {22} [style=dashed]; + 19 -> {20}; + 20 -> {21}; + 21 -> {13} [color=red]; + 21 -> {11} [color=green]; + 22 -> {23}; + 23 -> {24}; + 24 -> {25}; + 25 -> {26}; - subgraph cluster_9 { - color=red - 29 [label="Enter function getter" style="filled" fillcolor=red]; - 30 [label="Exit function getter" style="filled" fillcolor=red]; - } - 29 -> {30}; + subgraph cluster_9 { + color=red + 27 [label="Enter function getter" style="filled" fillcolor=red]; + 28 [label="Exit function getter" style="filled" fillcolor=red]; + } + 27 -> {28}; + + subgraph cluster_10 { + color=red + 29 [label="Enter property" style="filled" fillcolor=red]; + 30 [label="Access variable R|/s|"]; + 31 [label="Exit property" style="filled" fillcolor=red]; + } + 29 -> {30}; + 30 -> {31}; + 31 -> {7} [color=green]; - subgraph cluster_10 { - color=red - 31 [label="Enter function foo" style="filled" fillcolor=red]; subgraph cluster_11 { - color=blue - 32 [label="Enter block"]; - 33 [label="Function call: this@R|/B|.R|/B.foo|()"]; - 34 [label="Exit block"]; + color=red + 32 [label="Enter function foo" style="filled" fillcolor=red]; + subgraph cluster_12 { + color=blue + 33 [label="Enter block"]; + 34 [label="Function call: this@R|/B|.R|/B.foo|()"]; + 35 [label="Exit block"]; + } + 36 [label="Exit function foo" style="filled" fillcolor=red]; } - 35 [label="Exit function foo" style="filled" fillcolor=red]; - } - 31 -> {32}; - 32 -> {33}; - 33 -> {34}; - 34 -> {35}; + 32 -> {33}; + 33 -> {34}; + 34 -> {35}; + 35 -> {36}; -} + } diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/postponedLambdas.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/postponedLambdas.dot index 7beb72397e8..15444d623aa 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/postponedLambdas.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/postponedLambdas.dot @@ -48,6 +48,7 @@ digraph postponedLambdas_kt { 6 -> {7}; 7 -> {13}; 7 -> {8} [color=red]; + 7 -> {13} [style=dashed]; 8 -> {9}; 9 -> {10}; 10 -> {11}; diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/propertiesAndInitBlocks.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/propertiesAndInitBlocks.dot index 600a69725dc..9ec07b90617 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/propertiesAndInitBlocks.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/propertiesAndInitBlocks.dot @@ -85,106 +85,136 @@ digraph propertiesAndInitBlocks_kt { subgraph cluster_9 { color=red - 44 [label="Enter function foo" style="filled" fillcolor=red]; + 37 [label="Enter function foo" style="filled" fillcolor=red]; subgraph cluster_10 { color=blue - 45 [label="Enter block"]; - 46 [label="Const: Int(1)"]; - 47 [label="Const: Int(1)"]; - 48 [label="Function call: Int(1).R|kotlin/Int.plus|(...)"]; - 49 [label="Variable declaration: lval c: R|kotlin/Int|"]; - 50 [label="Function call: R|java/lang/Exception.Exception|()"]; - 51 [label="Throw: throw R|java/lang/Exception.Exception|()"]; - 52 [label="Stub" style="filled" fillcolor=gray]; - 53 [label="Exit block" style="filled" fillcolor=gray]; + 38 [label="Enter block"]; + 39 [label="Const: Int(1)"]; + 40 [label="Const: Int(1)"]; + 41 [label="Function call: Int(1).R|kotlin/Int.plus|(...)"]; + 42 [label="Variable declaration: lval c: R|kotlin/Int|"]; + 43 [label="Function call: R|java/lang/Exception.Exception|()"]; + 44 [label="Throw: throw R|java/lang/Exception.Exception|()"]; + 45 [label="Stub" style="filled" fillcolor=gray]; + 46 [label="Exit block" style="filled" fillcolor=gray]; } - 54 [label="Exit function foo" style="filled" fillcolor=red]; + 47 [label="Exit function foo" style="filled" fillcolor=red]; } - 44 -> {45}; - 45 -> {46}; - 46 -> {47}; - 47 -> {48}; - 48 -> {49}; - 49 -> {50}; - 50 -> {51}; - 51 -> {54}; - 51 -> {52} [style=dotted]; - 52 -> {53} [style=dotted]; - 53 -> {54} [style=dotted]; + 37 -> {38}; + 38 -> {39}; + 39 -> {40}; + 40 -> {41}; + 41 -> {42}; + 42 -> {43}; + 43 -> {44}; + 44 -> {47}; + 44 -> {45} [style=dotted]; + 45 -> {46} [style=dotted]; + 46 -> {47} [style=dotted]; subgraph cluster_11 { color=red - 55 [label="Enter function " style="filled" fillcolor=red]; - 56 [label="Delegated constructor call: super()"]; - 57 [label="Exit function " style="filled" fillcolor=red]; + 48 [label="Enter function " style="filled" fillcolor=red]; + 49 [label="Delegated constructor call: super()"]; + 50 [label="Exit function " style="filled" fillcolor=red]; } - 55 -> {56}; - 56 -> {57}; + 48 -> {49}; + 49 -> {50}; subgraph cluster_12 { color=red - 58 [label="Enter function getter" style="filled" fillcolor=red]; + 51 [label="Enter init block" style="filled" fillcolor=red]; subgraph cluster_13 { color=blue - 63 [label="Enter class GetterLocalClass" style="filled" fillcolor=red]; - subgraph cluster_14 { - color=blue - 59 [label="Enter block"]; - 60 [label="Exit local class "]; - 61 [label="Exit block"]; - } - 62 [label="Exit function getter" style="filled" fillcolor=red]; + 52 [label="Enter block"]; + 53 [label="Function call: R|java/lang/Exception.Exception|()"]; + 54 [label="Throw: throw R|java/lang/Exception.Exception|()"]; + 55 [label="Stub" style="filled" fillcolor=gray]; + 56 [label="Const: Int(1)" style="filled" fillcolor=gray]; + 57 [label="Exit block" style="filled" fillcolor=gray]; } + 58 [label="Exit init block" style="filled" fillcolor=red]; + } + 51 -> {52}; + 52 -> {53}; + 53 -> {54}; + 54 -> {58}; + 54 -> {55} [style=dotted]; + 55 -> {56} [style=dotted]; + 56 -> {57} [style=dotted]; + 57 -> {58} [style=dotted]; + 58 -> {36} [color=green]; + + subgraph cluster_14 { + color=red + 59 [label="Enter function getter" style="filled" fillcolor=red]; subgraph cluster_15 { color=blue - 65 [label="Enter init block" style="filled" fillcolor=red]; - subgraph cluster_16 { - color=blue - 66 [label="Enter block"]; - 67 [label="Function call: R|java/lang/Exception.Exception|()"]; - 68 [label="Throw: throw R|java/lang/Exception.Exception|()"]; - 69 [label="Stub" style="filled" fillcolor=gray]; - 70 [label="Exit block" style="filled" fillcolor=gray]; - } - 71 [label="Exit init block" style="filled" fillcolor=red]; + 60 [label="Enter block"]; + 61 [label="Exit local class "]; + 62 [label="Exit block"]; } - 64 [label="Exit class GetterLocalClass" style="filled" fillcolor=red]; + 63 [label="Exit function getter" style="filled" fillcolor=red]; } - 58 -> {59}; - 59 -> {60}; - 59 -> {72 65} [color=red]; - 60 -> {61}; - 61 -> {62}; - 63 -> {65} [color=green]; - 65 -> {66}; - 66 -> {67}; - 67 -> {68}; - 68 -> {71}; - 68 -> {69} [style=dotted]; - 69 -> {70} [style=dotted]; - 70 -> {71} [style=dotted]; - 71 -> {64} [color=green]; - - subgraph cluster_17 { - color=red - 72 [label="Enter function " style="filled" fillcolor=red]; - 73 [label="Delegated constructor call: super()"]; - 74 [label="Exit function " style="filled" fillcolor=red]; - } - 72 -> {73}; - 73 -> {74}; - - subgraph cluster_18 { - color=red - 75 [label="Enter property" style="filled" fillcolor=red]; - subgraph cluster_19 { + subgraph cluster_16 { + color=blue + 64 [label="Enter class GetterLocalClass" style="filled" fillcolor=red]; + subgraph cluster_17 { color=blue - 34 [label="Enter class InitializerLocalClass" style="filled" fillcolor=red]; - 76 [label="Postponed enter to lambda"]; + 65 [label="Part of class initialization"]; + 66 [label="Exit class GetterLocalClass" style="filled" fillcolor=red]; + } + 59 -> {60}; + 60 -> {61}; + 60 -> {67 70} [color=red]; + 61 -> {62}; + 61 -> {67 64} [color=green]; + 61 -> {67 64} [style=dashed]; + 62 -> {63}; + 64 -> {65} [color=green]; + 65 -> {66} [style=dotted]; + 65 -> {70} [color=green]; + 65 -> {70} [style=dashed]; + + subgraph cluster_18 { + color=red + 67 [label="Enter function " style="filled" fillcolor=red]; + 68 [label="Delegated constructor call: super()"]; + 69 [label="Exit function " style="filled" fillcolor=red]; + } + 67 -> {68}; + 68 -> {69}; + + subgraph cluster_19 { + color=red + 70 [label="Enter init block" style="filled" fillcolor=red]; subgraph cluster_20 { + color=blue + 71 [label="Enter block"]; + 72 [label="Function call: R|java/lang/Exception.Exception|()"]; + 73 [label="Throw: throw R|java/lang/Exception.Exception|()"]; + 74 [label="Stub" style="filled" fillcolor=gray]; + 75 [label="Exit block" style="filled" fillcolor=gray]; + } + 76 [label="Exit init block" style="filled" fillcolor=red]; + } + 70 -> {71}; + 71 -> {72}; + 72 -> {73}; + 73 -> {76}; + 73 -> {74} [style=dotted]; + 74 -> {75} [style=dotted]; + 75 -> {76} [style=dotted]; + 76 -> {66} [color=green]; + + subgraph cluster_21 { + color=red + 77 [label="Enter property" style="filled" fillcolor=red]; + 78 [label="Postponed enter to lambda"]; + subgraph cluster_22 { color=blue 26 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; - subgraph cluster_21 { + subgraph cluster_23 { color=blue 27 [label="Enter block"]; 28 [label="Exit local class "]; @@ -193,122 +223,111 @@ digraph propertiesAndInitBlocks_kt { 31 [label="Stub" style="filled" fillcolor=gray]; 32 [label="Exit block" style="filled" fillcolor=gray]; } - subgraph cluster_22 { + subgraph cluster_24 { color=blue - 36 [label="Enter init block" style="filled" fillcolor=red]; - subgraph cluster_23 { + 34 [label="Enter class InitializerLocalClass" style="filled" fillcolor=red]; + subgraph cluster_25 { color=blue - 37 [label="Enter block"]; - 38 [label="Function call: R|java/lang/Exception.Exception|()"]; - 39 [label="Throw: throw R|java/lang/Exception.Exception|()"]; - 40 [label="Stub" style="filled" fillcolor=gray]; - 41 [label="Const: Int(1)" style="filled" fillcolor=gray]; - 42 [label="Exit block" style="filled" fillcolor=gray]; + 35 [label="Part of class initialization"]; + 36 [label="Exit class InitializerLocalClass" style="filled" fillcolor=red]; } - 43 [label="Exit init block" style="filled" fillcolor=red]; + 33 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 35 [label="Exit class InitializerLocalClass" style="filled" fillcolor=red]; + 79 [label="Postponed exit from lambda"]; + 80 [label="Function call: R|/run|(...)"]; + 81 [label="Exit property" style="filled" fillcolor=red]; } - 33 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; - } - 77 [label="Postponed exit from lambda"]; - 78 [label="Function call: R|/run|(...)"]; - 79 [label="Exit property" style="filled" fillcolor=red]; - } - 75 -> {76}; - 76 -> {26}; - 76 -> {77} [color=red]; - 77 -> {78}; - 78 -> {79}; - 26 -> {33 27}; - 27 -> {28}; - 27 -> {44 55 36} [color=red]; - 28 -> {29}; - 29 -> {30}; - 30 -> {33}; - 30 -> {31} [style=dotted]; - 31 -> {32} [style=dotted]; - 32 -> {33} [style=dotted]; - 33 -> {77} [color=green]; - 33 -> {26} [color=green style=dashed]; - 34 -> {36} [color=green]; - 36 -> {37}; - 37 -> {38}; - 38 -> {39}; - 39 -> {43}; - 39 -> {40} [style=dotted]; - 40 -> {41} [style=dotted]; - 41 -> {42} [style=dotted]; - 42 -> {43} [style=dotted]; - 43 -> {35} [color=green]; + 77 -> {78}; + 78 -> {26}; + 78 -> {79} [color=red]; + 78 -> {26} [style=dashed]; + 79 -> {80}; + 80 -> {81}; + 26 -> {33 27}; + 27 -> {28}; + 27 -> {37 48 51} [color=red]; + 28 -> {29}; + 28 -> {48 34} [color=green]; + 28 -> {48 34} [style=dashed]; + 29 -> {30}; + 30 -> {33}; + 30 -> {31} [style=dotted]; + 31 -> {32} [style=dotted]; + 32 -> {33} [style=dotted]; + 33 -> {79} [color=green]; + 33 -> {26} [color=green style=dashed]; + 34 -> {35} [color=green]; + 35 -> {36} [style=dotted]; + 35 -> {51} [color=green]; + 35 -> {51} [style=dashed]; - subgraph cluster_24 { - color=red - 80 [label="Enter function getter" style="filled" fillcolor=red]; - 81 [label="Exit function getter" style="filled" fillcolor=red]; - } - 80 -> {81}; + subgraph cluster_26 { + color=red + 82 [label="Enter function getter" style="filled" fillcolor=red]; + 83 [label="Exit function getter" style="filled" fillcolor=red]; + } + 82 -> {83}; - subgraph cluster_25 { - color=red - 82 [label="Enter property" style="filled" fillcolor=red]; - subgraph cluster_26 { - color=blue - 83 [label="Try expression enter"]; subgraph cluster_27 { - color=blue - 84 [label="Try main block enter"]; + color=red + 84 [label="Enter property" style="filled" fillcolor=red]; subgraph cluster_28 { color=blue - 85 [label="Enter block"]; - 86 [label="Const: Int(1)"]; - 87 [label="Exit block"]; + 85 [label="Try expression enter"]; + subgraph cluster_29 { + color=blue + 86 [label="Try main block enter"]; + subgraph cluster_30 { + color=blue + 87 [label="Enter block"]; + 88 [label="Const: Int(1)"]; + 89 [label="Exit block"]; + } + 90 [label="Try main block exit"]; + } + subgraph cluster_31 { + color=blue + 91 [label="Enter finally"]; + subgraph cluster_32 { + color=blue + 92 [label="Enter block"]; + 93 [label="Const: Int(0)"]; + 94 [label="Exit block"]; + } + 95 [label="Exit finally"]; + } + subgraph cluster_33 { + color=blue + 96 [label="Catch enter"]; + subgraph cluster_34 { + color=blue + 97 [label="Enter block"]; + 98 [label="Const: Int(2)"]; + 99 [label="Exit block"]; + } + 100 [label="Catch exit"]; + } + 101 [label="Try expression exit"]; } - 88 [label="Try main block exit"]; + 102 [label="Exit property" style="filled" fillcolor=red]; } - subgraph cluster_29 { - color=blue - 89 [label="Enter finally"]; - subgraph cluster_30 { - color=blue - 90 [label="Enter block"]; - 91 [label="Const: Int(0)"]; - 92 [label="Exit block"]; - } - 93 [label="Exit finally"]; - } - subgraph cluster_31 { - color=blue - 94 [label="Catch enter"]; - subgraph cluster_32 { - color=blue - 95 [label="Enter block"]; - 96 [label="Const: Int(2)"]; - 97 [label="Exit block"]; - } - 98 [label="Catch exit"]; - } - 99 [label="Try expression exit"]; - } - 100 [label="Exit property" style="filled" fillcolor=red]; - } - 82 -> {83}; - 83 -> {84}; - 84 -> {100 94 89 85}; - 85 -> {86}; - 86 -> {87}; - 87 -> {88}; - 88 -> {99}; - 89 -> {90}; - 90 -> {91}; - 91 -> {92}; - 92 -> {93}; - 93 -> {99}; - 94 -> {100 95}; - 95 -> {96}; - 96 -> {97}; - 97 -> {98}; - 98 -> {99}; - 99 -> {100}; + 84 -> {85}; + 85 -> {86}; + 86 -> {102 96 91 87}; + 87 -> {88}; + 88 -> {89}; + 89 -> {90}; + 90 -> {101}; + 91 -> {92}; + 92 -> {93}; + 93 -> {94}; + 94 -> {95}; + 95 -> {101}; + 96 -> {102 97}; + 97 -> {98}; + 98 -> {99}; + 99 -> {100}; + 100 -> {101}; + 101 -> {102}; -} + } diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/returnValuesFromLambda.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/returnValuesFromLambda.dot index e148feb6c36..8a7bf68bdbf 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/returnValuesFromLambda.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/returnValuesFromLambda.dot @@ -94,6 +94,7 @@ digraph returnValuesFromLambda_kt { 13 -> {14}; 14 -> {21}; 14 -> {16} [color=red]; + 14 -> {21} [style=dashed]; 15 -> {17} [color=red]; 16 -> {17} [color=green]; 17 -> {18}; @@ -152,6 +153,7 @@ digraph returnValuesFromLambda_kt { 40 -> {41}; 41 -> {48}; 41 -> {43} [color=red]; + 41 -> {48} [style=dashed]; 42 -> {44} [color=red]; 43 -> {44} [color=green]; 44 -> {45}; @@ -199,6 +201,7 @@ digraph returnValuesFromLambda_kt { 56 -> {57}; 57 -> {65}; 57 -> {59} [color=red]; + 57 -> {65} [style=dashed]; 58 -> {60} [style=dotted]; 59 -> {60} [style=dotted]; 60 -> {64 61} [style=dotted]; diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/secondaryConstructorCfg.dot b/compiler/fir/analysis-tests/testData/resolve/problems/secondaryConstructorCfg.dot index a1d857b8371..af42ccd2b1b 100644 --- a/compiler/fir/analysis-tests/testData/resolve/problems/secondaryConstructorCfg.dot +++ b/compiler/fir/analysis-tests/testData/resolve/problems/secondaryConstructorCfg.dot @@ -8,109 +8,130 @@ digraph secondaryConstructorCfg_kt { 0 [label="Enter class B" style="filled" fillcolor=red]; subgraph cluster_1 { color=blue - 2 [label="Enter property" style="filled" fillcolor=red]; - 3 [label="Access variable R|/p0|"]; - 4 [label="Exit property" style="filled" fillcolor=red]; - } - subgraph cluster_2 { - color=blue - 5 [label="Enter property" style="filled" fillcolor=red]; - 6 [label="Access variable R|/p0|"]; - 7 [label="Access variable R|kotlin/String.length|"]; - 8 [label="Exit property" style="filled" fillcolor=red]; - } - subgraph cluster_3 { - color=blue - 9 [label="Enter init block" style="filled" fillcolor=red]; - subgraph cluster_4 { + 1 [label="Part of class initialization"]; + subgraph cluster_2 { color=blue - 10 [label="Enter block"]; - 11 [label="Access variable R|/p0|"]; - 12 [label="Access variable R|kotlin/String.length|"]; - 13 [label="Assignment: R|/B.p1|"]; - 14 [label="Const: String()"]; - 15 [label="Assignment: R|/B.p3|"]; - 16 [label="Exit block"]; + 2 [label="Part of class initialization"]; + subgraph cluster_3 { + color=blue + 3 [label="Part of class initialization"]; + 4 [label="Exit class B" style="filled" fillcolor=red]; + } + 0 -> {1} [color=green]; + 1 -> {2} [style=dotted]; + 1 -> {10} [color=green]; + 1 -> {10} [style=dashed]; + 2 -> {3} [style=dotted]; + 2 -> {15} [color=green]; + 2 -> {15} [style=dashed]; + 3 -> {4} [style=dotted]; + 3 -> {31} [color=green]; + 3 -> {31} [style=dashed]; + + subgraph cluster_4 { + color=red + 5 [label="Enter function " style="filled" fillcolor=red]; + 6 [label="Delegated constructor call: super()"]; + 7 [label="Exit function " style="filled" fillcolor=red]; + } + 5 -> {6}; + 6 -> {7}; + + subgraph cluster_5 { + color=red + 8 [label="Enter function getter" style="filled" fillcolor=red]; + 9 [label="Exit function getter" style="filled" fillcolor=red]; + } + 8 -> {9}; + + subgraph cluster_6 { + color=red + 10 [label="Enter property" style="filled" fillcolor=red]; + 11 [label="Access variable R|/p0|"]; + 12 [label="Exit property" style="filled" fillcolor=red]; + } + 10 -> {11}; + 11 -> {12}; + 12 -> {2} [color=green]; + + subgraph cluster_7 { + color=red + 13 [label="Enter function getter" style="filled" fillcolor=red]; + 14 [label="Exit function getter" style="filled" fillcolor=red]; + } + 13 -> {14}; + + subgraph cluster_8 { + color=red + 15 [label="Enter property" style="filled" fillcolor=red]; + 16 [label="Access variable R|/p0|"]; + 17 [label="Access variable R|kotlin/String.length|"]; + 18 [label="Exit property" style="filled" fillcolor=red]; + } + 15 -> {16}; + 16 -> {17}; + 17 -> {18}; + 18 -> {3} [color=green]; + + subgraph cluster_9 { + color=red + 19 [label="Enter function getter" style="filled" fillcolor=red]; + 20 [label="Exit function getter" style="filled" fillcolor=red]; + } + 19 -> {20}; + + subgraph cluster_10 { + color=red + 21 [label="Enter function setter" style="filled" fillcolor=red]; + 22 [label="Exit function setter" style="filled" fillcolor=red]; + } + 21 -> {22}; + + subgraph cluster_11 { + color=red + 23 [label="Enter function " style="filled" fillcolor=red]; + 24 [label="Access variable R|/p0|"]; + 25 [label="Delegated constructor call: this(...)"]; + subgraph cluster_12 { + color=blue + 26 [label="Enter block"]; + 27 [label="Access variable R|/p1|"]; + 28 [label="Assignment: R|/B.p3|"]; + 29 [label="Exit block"]; + } + 30 [label="Exit function " style="filled" fillcolor=red]; + } + 23 -> {24}; + 24 -> {25}; + 25 -> {26}; + 26 -> {27}; + 27 -> {28}; + 28 -> {29}; + 29 -> {30}; + + subgraph cluster_13 { + color=red + 31 [label="Enter init block" style="filled" fillcolor=red]; + subgraph cluster_14 { + color=blue + 32 [label="Enter block"]; + 33 [label="Access variable R|/p0|"]; + 34 [label="Access variable R|kotlin/String.length|"]; + 35 [label="Assignment: R|/B.p1|"]; + 36 [label="Const: String()"]; + 37 [label="Assignment: R|/B.p3|"]; + 38 [label="Exit block"]; + } + 39 [label="Exit init block" style="filled" fillcolor=red]; + } + 31 -> {32}; + 32 -> {33}; + 33 -> {34}; + 34 -> {35}; + 35 -> {36}; + 36 -> {37}; + 37 -> {38}; + 38 -> {39}; + 39 -> {4} [color=green]; + } - 17 [label="Exit init block" style="filled" fillcolor=red]; - } - 1 [label="Exit class B" style="filled" fillcolor=red]; - } - 0 -> {2} [color=green]; - 2 -> {3}; - 3 -> {4}; - 4 -> {5} [color=green]; - 5 -> {6}; - 6 -> {7}; - 7 -> {8}; - 8 -> {9} [color=green]; - 9 -> {10}; - 10 -> {11}; - 11 -> {12}; - 12 -> {13}; - 13 -> {14}; - 14 -> {15}; - 15 -> {16}; - 16 -> {17}; - 17 -> {1} [color=green]; - - subgraph cluster_5 { - color=red - 18 [label="Enter function " style="filled" fillcolor=red]; - 19 [label="Delegated constructor call: super()"]; - 20 [label="Exit function " style="filled" fillcolor=red]; - } - 18 -> {19}; - 19 -> {20}; - - subgraph cluster_6 { - color=red - 21 [label="Enter function getter" style="filled" fillcolor=red]; - 22 [label="Exit function getter" style="filled" fillcolor=red]; - } - 21 -> {22}; - - subgraph cluster_7 { - color=red - 23 [label="Enter function getter" style="filled" fillcolor=red]; - 24 [label="Exit function getter" style="filled" fillcolor=red]; - } - 23 -> {24}; - - subgraph cluster_8 { - color=red - 25 [label="Enter function getter" style="filled" fillcolor=red]; - 26 [label="Exit function getter" style="filled" fillcolor=red]; - } - 25 -> {26}; - - subgraph cluster_9 { - color=red - 27 [label="Enter function setter" style="filled" fillcolor=red]; - 28 [label="Exit function setter" style="filled" fillcolor=red]; - } - 27 -> {28}; - - subgraph cluster_10 { - color=red - 29 [label="Enter function " style="filled" fillcolor=red]; - 30 [label="Access variable R|/p0|"]; - 31 [label="Delegated constructor call: this(...)"]; - subgraph cluster_11 { - color=blue - 32 [label="Enter block"]; - 33 [label="Access variable R|/p1|"]; - 34 [label="Assignment: R|/B.p3|"]; - 35 [label="Exit block"]; - } - 36 [label="Exit function " style="filled" fillcolor=red]; - } - 29 -> {30}; - 30 -> {31}; - 31 -> {32}; - 32 -> {33}; - 33 -> {34}; - 34 -> {35}; - 35 -> {36}; - -} diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.dot index 2d49886cd58..05d0ba4ab59 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.dot @@ -319,186 +319,193 @@ digraph boundSmartcasts_kt { 115 [label="Enter class D" style="filled" fillcolor=red]; subgraph cluster_28 { color=blue - 117 [label="Enter property" style="filled" fillcolor=red]; - 118 [label="Access variable R|/any|"]; - 119 [label="Exit property" style="filled" fillcolor=red]; + 116 [label="Part of class initialization"]; + 117 [label="Exit class D" style="filled" fillcolor=red]; } - 116 [label="Exit class D" style="filled" fillcolor=red]; - } - 115 -> {117} [color=green]; - 117 -> {118}; - 118 -> {119}; - 119 -> {116} [color=green]; + 115 -> {116} [color=green]; + 116 -> {117} [style=dotted]; + 116 -> {123} [color=green]; + 116 -> {123} [style=dashed]; - subgraph cluster_29 { - color=red - 120 [label="Enter function " style="filled" fillcolor=red]; - 121 [label="Delegated constructor call: super()"]; - 122 [label="Exit function " style="filled" fillcolor=red]; - } - 120 -> {121}; - 121 -> {122}; + subgraph cluster_29 { + color=red + 118 [label="Enter function " style="filled" fillcolor=red]; + 119 [label="Delegated constructor call: super()"]; + 120 [label="Exit function " style="filled" fillcolor=red]; + } + 118 -> {119}; + 119 -> {120}; - subgraph cluster_30 { - color=red - 123 [label="Enter function getter" style="filled" fillcolor=red]; - 124 [label="Exit function getter" style="filled" fillcolor=red]; - } - 123 -> {124}; + subgraph cluster_30 { + color=red + 121 [label="Enter function getter" style="filled" fillcolor=red]; + 122 [label="Exit function getter" style="filled" fillcolor=red]; + } + 121 -> {122}; + + subgraph cluster_31 { + color=red + 123 [label="Enter property" style="filled" fillcolor=red]; + 124 [label="Access variable R|/any|"]; + 125 [label="Exit property" style="filled" fillcolor=red]; + } + 123 -> {124}; + 124 -> {125}; + 125 -> {117} [color=green]; - subgraph cluster_31 { - color=red - 125 [label="Enter function baz" style="filled" fillcolor=red]; subgraph cluster_32 { - color=blue - 126 [label="Enter block"]; - 127 [label="Exit block"]; + color=red + 126 [label="Enter function baz" style="filled" fillcolor=red]; + subgraph cluster_33 { + color=blue + 127 [label="Enter block"]; + 128 [label="Exit block"]; + } + 129 [label="Exit function baz" style="filled" fillcolor=red]; } - 128 [label="Exit function baz" style="filled" fillcolor=red]; - } - 125 -> {126}; - 126 -> {127}; - 127 -> {128}; + 126 -> {127}; + 127 -> {128}; + 128 -> {129}; - subgraph cluster_33 { - color=red - 129 [label="Enter function test_5" style="filled" fillcolor=red]; subgraph cluster_34 { - color=blue - 130 [label="Enter block"]; - 131 [label="Access variable R|/d|"]; - 132 [label="Access variable R|/D.any|"]; - 133 [label="Exit lhs of ?:"]; - 134 [label="Enter rhs of ?:"]; - 135 [label="Jump: ^test_5 Unit"]; - 136 [label="Stub" style="filled" fillcolor=gray]; - 137 [label="Lhs of ?: is not null"]; - 138 [label="Exit ?:"]; - 139 [label="Variable declaration: lval a: R|kotlin/Any|"]; - 140 [label="Access variable R|/a|"]; - 141 [label="Function call: R|/a|.R|/baz|()"]; - 142 [label="Access variable R|/d|"]; - 143 [label="Access variable R|/D.any|"]; - 144 [label="Function call: R|/d|.R|/D.any|.R|/baz|()"]; - 145 [label="Access variable R|/a|"]; - 146 [label="Type operator: (R|/a| as R|A|)"]; - 147 [label="Access variable R|/a|"]; - 148 [label="Function call: R|/a|.R|/A.foo|()"]; - 149 [label="Exit block"]; + color=red + 130 [label="Enter function test_5" style="filled" fillcolor=red]; + subgraph cluster_35 { + color=blue + 131 [label="Enter block"]; + 132 [label="Access variable R|/d|"]; + 133 [label="Access variable R|/D.any|"]; + 134 [label="Exit lhs of ?:"]; + 135 [label="Enter rhs of ?:"]; + 136 [label="Jump: ^test_5 Unit"]; + 137 [label="Stub" style="filled" fillcolor=gray]; + 138 [label="Lhs of ?: is not null"]; + 139 [label="Exit ?:"]; + 140 [label="Variable declaration: lval a: R|kotlin/Any|"]; + 141 [label="Access variable R|/a|"]; + 142 [label="Function call: R|/a|.R|/baz|()"]; + 143 [label="Access variable R|/d|"]; + 144 [label="Access variable R|/D.any|"]; + 145 [label="Function call: R|/d|.R|/D.any|.R|/baz|()"]; + 146 [label="Access variable R|/a|"]; + 147 [label="Type operator: (R|/a| as R|A|)"]; + 148 [label="Access variable R|/a|"]; + 149 [label="Function call: R|/a|.R|/A.foo|()"]; + 150 [label="Exit block"]; + } + 151 [label="Exit function test_5" style="filled" fillcolor=red]; } - 150 [label="Exit function test_5" style="filled" fillcolor=red]; - } - 129 -> {130}; - 130 -> {131}; - 131 -> {132}; - 132 -> {133}; - 133 -> {137 134}; - 134 -> {135}; - 135 -> {150}; - 135 -> {136} [style=dotted]; - 136 -> {138} [style=dotted]; - 137 -> {138}; - 138 -> {139}; - 139 -> {140}; - 140 -> {141}; - 141 -> {142}; - 142 -> {143}; - 143 -> {144}; - 144 -> {145}; - 145 -> {146}; - 146 -> {147}; - 147 -> {148}; - 148 -> {149}; - 149 -> {150}; + 130 -> {131}; + 131 -> {132}; + 132 -> {133}; + 133 -> {134}; + 134 -> {138 135}; + 135 -> {136}; + 136 -> {151}; + 136 -> {137} [style=dotted]; + 137 -> {139} [style=dotted]; + 138 -> {139}; + 139 -> {140}; + 140 -> {141}; + 141 -> {142}; + 142 -> {143}; + 143 -> {144}; + 144 -> {145}; + 145 -> {146}; + 146 -> {147}; + 147 -> {148}; + 148 -> {149}; + 149 -> {150}; + 150 -> {151}; - subgraph cluster_35 { - color=red - 151 [label="Enter function test_6" style="filled" fillcolor=red]; subgraph cluster_36 { - color=blue - 152 [label="Enter block"]; - 153 [label="Access variable R|/d1|"]; - 154 [label="Access variable R|/D.any|"]; - 155 [label="Variable declaration: lval a: R|kotlin/Any?|"]; - 156 [label="Access variable R|/a|"]; - 157 [label="Type operator: (R|/a| as R|A|)"]; - 158 [label="Access variable R|/a|"]; - 159 [label="Function call: R|/a|.R|/A.foo|()"]; - 160 [label="Access variable R|/d1|"]; - 161 [label="Access variable R|/D.any|"]; - 162 [label="Function call: R|/d1|.R|/D.any|.R|/A.foo|()"]; - 163 [label="Access variable R|/d1|"]; - 164 [label="Access variable R|/D.any|"]; - 165 [label="Function call: R|/d1|.R|/D.any|.R|/baz|()"]; - 166 [label="Exit block"]; + color=red + 152 [label="Enter function test_6" style="filled" fillcolor=red]; + subgraph cluster_37 { + color=blue + 153 [label="Enter block"]; + 154 [label="Access variable R|/d1|"]; + 155 [label="Access variable R|/D.any|"]; + 156 [label="Variable declaration: lval a: R|kotlin/Any?|"]; + 157 [label="Access variable R|/a|"]; + 158 [label="Type operator: (R|/a| as R|A|)"]; + 159 [label="Access variable R|/a|"]; + 160 [label="Function call: R|/a|.R|/A.foo|()"]; + 161 [label="Access variable R|/d1|"]; + 162 [label="Access variable R|/D.any|"]; + 163 [label="Function call: R|/d1|.R|/D.any|.R|/A.foo|()"]; + 164 [label="Access variable R|/d1|"]; + 165 [label="Access variable R|/D.any|"]; + 166 [label="Function call: R|/d1|.R|/D.any|.R|/baz|()"]; + 167 [label="Exit block"]; + } + 168 [label="Exit function test_6" style="filled" fillcolor=red]; } - 167 [label="Exit function test_6" style="filled" fillcolor=red]; - } - 151 -> {152}; - 152 -> {153}; - 153 -> {154}; - 154 -> {155}; - 155 -> {156}; - 156 -> {157}; - 157 -> {158}; - 158 -> {159}; - 159 -> {160}; - 160 -> {161}; - 161 -> {162}; - 162 -> {163}; - 163 -> {164}; - 164 -> {165}; - 165 -> {166}; - 166 -> {167}; + 152 -> {153}; + 153 -> {154}; + 154 -> {155}; + 155 -> {156}; + 156 -> {157}; + 157 -> {158}; + 158 -> {159}; + 159 -> {160}; + 160 -> {161}; + 161 -> {162}; + 162 -> {163}; + 163 -> {164}; + 164 -> {165}; + 165 -> {166}; + 166 -> {167}; + 167 -> {168}; - subgraph cluster_37 { - color=red - 168 [label="Enter function test_7" style="filled" fillcolor=red]; subgraph cluster_38 { - color=blue - 169 [label="Enter block"]; - 170 [label="Access variable R|/d1|"]; - 171 [label="Enter safe call"]; - 172 [label="Access variable R|/D.any|"]; - 173 [label="Exit safe call"]; - 174 [label="Variable declaration: lval a: R|kotlin/Any?|"]; - 175 [label="Access variable R|/d2|"]; - 176 [label="Enter safe call"]; - 177 [label="Access variable R|/D.any|"]; - 178 [label="Exit safe call"]; - 179 [label="Variable declaration: lval b: R|kotlin/Any?|"]; - 180 [label="Access variable R|/a|"]; - 181 [label="Type operator: (R|/a| as R|A|)"]; - 182 [label="Access variable R|/a|"]; - 183 [label="Function call: R|/a|.R|/A.foo|()"]; - 184 [label="Access variable R|/b|"]; - 185 [label="Type operator: (R|/b| as R|B|)"]; - 186 [label="Access variable R|/b|"]; - 187 [label="Function call: R|/b|.R|/B.bar|()"]; - 188 [label="Exit block"]; + color=red + 169 [label="Enter function test_7" style="filled" fillcolor=red]; + subgraph cluster_39 { + color=blue + 170 [label="Enter block"]; + 171 [label="Access variable R|/d1|"]; + 172 [label="Enter safe call"]; + 173 [label="Access variable R|/D.any|"]; + 174 [label="Exit safe call"]; + 175 [label="Variable declaration: lval a: R|kotlin/Any?|"]; + 176 [label="Access variable R|/d2|"]; + 177 [label="Enter safe call"]; + 178 [label="Access variable R|/D.any|"]; + 179 [label="Exit safe call"]; + 180 [label="Variable declaration: lval b: R|kotlin/Any?|"]; + 181 [label="Access variable R|/a|"]; + 182 [label="Type operator: (R|/a| as R|A|)"]; + 183 [label="Access variable R|/a|"]; + 184 [label="Function call: R|/a|.R|/A.foo|()"]; + 185 [label="Access variable R|/b|"]; + 186 [label="Type operator: (R|/b| as R|B|)"]; + 187 [label="Access variable R|/b|"]; + 188 [label="Function call: R|/b|.R|/B.bar|()"]; + 189 [label="Exit block"]; + } + 190 [label="Exit function test_7" style="filled" fillcolor=red]; } - 189 [label="Exit function test_7" style="filled" fillcolor=red]; - } - 168 -> {169}; - 169 -> {170}; - 170 -> {171 173}; - 171 -> {172}; - 172 -> {173}; - 173 -> {174}; - 174 -> {175}; - 175 -> {176 178}; - 176 -> {177}; - 177 -> {178}; - 178 -> {179}; - 179 -> {180}; - 180 -> {181}; - 181 -> {182}; - 182 -> {183}; - 183 -> {184}; - 184 -> {185}; - 185 -> {186}; - 186 -> {187}; - 187 -> {188}; - 188 -> {189}; + 169 -> {170}; + 170 -> {171}; + 171 -> {172 174}; + 172 -> {173}; + 173 -> {174}; + 174 -> {175}; + 175 -> {176}; + 176 -> {177 179}; + 177 -> {178}; + 178 -> {179}; + 179 -> {180}; + 180 -> {181}; + 181 -> {182}; + 182 -> {183}; + 183 -> {184}; + 184 -> {185}; + 185 -> {186}; + 186 -> {187}; + 187 -> {188}; + 188 -> {189}; + 189 -> {190}; -} + } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/functionCallBound.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/functionCallBound.dot index 5e1e50761c0..20fbe20d16a 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/functionCallBound.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/functionCallBound.dot @@ -24,100 +24,107 @@ digraph functionCallBound_kt { 5 [label="Enter class Sub" style="filled" fillcolor=red]; subgraph cluster_3 { color=blue - 7 [label="Enter property" style="filled" fillcolor=red]; - 8 [label="Access variable R|/data|"]; - 9 [label="Exit property" style="filled" fillcolor=red]; + 6 [label="Part of class initialization"]; + 7 [label="Exit class Sub" style="filled" fillcolor=red]; } - 6 [label="Exit class Sub" style="filled" fillcolor=red]; - } - 5 -> {7} [color=green]; - 7 -> {8}; - 8 -> {9}; - 9 -> {6} [color=green]; + 5 -> {6} [color=green]; + 6 -> {7} [style=dotted]; + 6 -> {13} [color=green]; + 6 -> {13} [style=dashed]; - subgraph cluster_4 { - color=red - 10 [label="Enter function " style="filled" fillcolor=red]; - 11 [label="Delegated constructor call: super()"]; - 12 [label="Exit function " style="filled" fillcolor=red]; - } - 10 -> {11}; - 11 -> {12}; + subgraph cluster_4 { + color=red + 8 [label="Enter function " style="filled" fillcolor=red]; + 9 [label="Delegated constructor call: super()"]; + 10 [label="Exit function " style="filled" fillcolor=red]; + } + 8 -> {9}; + 9 -> {10}; - subgraph cluster_5 { - color=red - 13 [label="Enter function getter" style="filled" fillcolor=red]; - 14 [label="Exit function getter" style="filled" fillcolor=red]; - } - 13 -> {14}; + subgraph cluster_5 { + color=red + 11 [label="Enter function getter" style="filled" fillcolor=red]; + 12 [label="Exit function getter" style="filled" fillcolor=red]; + } + 11 -> {12}; + + subgraph cluster_6 { + color=red + 13 [label="Enter property" style="filled" fillcolor=red]; + 14 [label="Access variable R|/data|"]; + 15 [label="Exit property" style="filled" fillcolor=red]; + } + 13 -> {14}; + 14 -> {15}; + 15 -> {7} [color=green]; - subgraph cluster_6 { - color=red - 15 [label="Enter function isOk" style="filled" fillcolor=red]; subgraph cluster_7 { - color=blue - 16 [label="Enter block"]; - 17 [label="Const: Boolean(true)"]; - 18 [label="Jump: ^isOk Boolean(true)"]; - 19 [label="Stub" style="filled" fillcolor=gray]; - 20 [label="Exit block" style="filled" fillcolor=gray]; + color=red + 16 [label="Enter function isOk" style="filled" fillcolor=red]; + subgraph cluster_8 { + color=blue + 17 [label="Enter block"]; + 18 [label="Const: Boolean(true)"]; + 19 [label="Jump: ^isOk Boolean(true)"]; + 20 [label="Stub" style="filled" fillcolor=gray]; + 21 [label="Exit block" style="filled" fillcolor=gray]; + } + 22 [label="Exit function isOk" style="filled" fillcolor=red]; } - 21 [label="Exit function isOk" style="filled" fillcolor=red]; - } - 15 -> {16}; - 16 -> {17}; - 17 -> {18}; - 18 -> {21}; - 18 -> {19} [style=dotted]; - 19 -> {20} [style=dotted]; - 20 -> {21} [style=dotted]; + 16 -> {17}; + 17 -> {18}; + 18 -> {19}; + 19 -> {22}; + 19 -> {20} [style=dotted]; + 20 -> {21} [style=dotted]; + 21 -> {22} [style=dotted]; - subgraph cluster_8 { - color=red - 22 [label="Enter function check" style="filled" fillcolor=red]; subgraph cluster_9 { - color=blue - 23 [label="Enter block"]; + color=red + 23 [label="Enter function check" style="filled" fillcolor=red]; subgraph cluster_10 { color=blue - 24 [label="Enter when"]; + 24 [label="Enter block"]; subgraph cluster_11 { color=blue - 25 [label="Enter when branch condition "]; - 26 [label="Access variable R|/base|"]; - 27 [label="Type operator: (R|/base| as? R|Sub|)"]; - 28 [label="Enter safe call"]; - 29 [label="Function call: $subj$.R|/isOk|()"]; - 30 [label="Exit safe call"]; - 31 [label="Const: Boolean(true)"]; - 32 [label="Equality operator =="]; - 33 [label="Exit when branch condition"]; + 25 [label="Enter when"]; + subgraph cluster_12 { + color=blue + 26 [label="Enter when branch condition "]; + 27 [label="Access variable R|/base|"]; + 28 [label="Type operator: (R|/base| as? R|Sub|)"]; + 29 [label="Enter safe call"]; + 30 [label="Function call: $subj$.R|/isOk|()"]; + 31 [label="Exit safe call"]; + 32 [label="Const: Boolean(true)"]; + 33 [label="Equality operator =="]; + 34 [label="Exit when branch condition"]; + } + subgraph cluster_13 { + color=blue + 35 [label="Enter when branch condition else"]; + 36 [label="Exit when branch condition"]; + } + 37 [label="Enter when branch result"]; + subgraph cluster_14 { + color=blue + 38 [label="Enter block"]; + 39 [label="Access variable R|/base|"]; + 40 [label="Exit block"]; + } + 41 [label="Exit when branch result"]; + 42 [label="Enter when branch result"]; + subgraph cluster_15 { + color=blue + 43 [label="Enter block"]; + 44 [label="Access variable R|/base|"]; + 45 [label="Access variable R|/Sub.data|"]; + 46 [label="Exit block"]; + } + 47 [label="Exit when branch result"]; + 48 [label="Exit when"]; } - subgraph cluster_12 { - color=blue - 34 [label="Enter when branch condition else"]; - 35 [label="Exit when branch condition"]; - } - 36 [label="Enter when branch result"]; - subgraph cluster_13 { - color=blue - 37 [label="Enter block"]; - 38 [label="Access variable R|/base|"]; - 39 [label="Exit block"]; - } - 40 [label="Exit when branch result"]; - 41 [label="Enter when branch result"]; - subgraph cluster_14 { - color=blue - 42 [label="Enter block"]; - 43 [label="Access variable R|/base|"]; - 44 [label="Access variable R|/Sub.data|"]; - 45 [label="Exit block"]; - } - 46 [label="Exit when branch result"]; - 47 [label="Exit when"]; - } - 48 [label="Jump: ^check when () { + 49 [label="Jump: ^check when () { ==((R|/base| as? R|Sub|)?.{ $subj$.R|/isOk|() }, Boolean(true)) -> { R|/base|.R|/Sub.data| } @@ -126,40 +133,40 @@ digraph functionCallBound_kt { } } "]; - 49 [label="Stub" style="filled" fillcolor=gray]; - 50 [label="Exit block" style="filled" fillcolor=gray]; + 50 [label="Stub" style="filled" fillcolor=gray]; + 51 [label="Exit block" style="filled" fillcolor=gray]; + } + 52 [label="Exit function check" style="filled" fillcolor=red]; } - 51 [label="Exit function check" style="filled" fillcolor=red]; - } - 22 -> {23}; - 23 -> {24}; - 24 -> {25}; - 25 -> {26}; - 26 -> {27}; - 27 -> {28 30}; - 28 -> {29}; - 29 -> {30}; - 30 -> {31}; - 31 -> {32}; - 32 -> {33}; - 33 -> {41 34}; - 34 -> {35}; - 35 -> {36}; - 36 -> {37}; - 37 -> {38}; - 38 -> {39}; - 39 -> {40}; - 40 -> {47}; - 41 -> {42}; - 42 -> {43}; - 43 -> {44}; - 44 -> {45}; - 45 -> {46}; - 46 -> {47}; - 47 -> {48}; - 48 -> {51}; - 48 -> {49} [style=dotted]; - 49 -> {50} [style=dotted]; - 50 -> {51} [style=dotted]; + 23 -> {24}; + 24 -> {25}; + 25 -> {26}; + 26 -> {27}; + 27 -> {28}; + 28 -> {29 31}; + 29 -> {30}; + 30 -> {31}; + 31 -> {32}; + 32 -> {33}; + 33 -> {34}; + 34 -> {42 35}; + 35 -> {36}; + 36 -> {37}; + 37 -> {38}; + 38 -> {39}; + 39 -> {40}; + 40 -> {41}; + 41 -> {48}; + 42 -> {43}; + 43 -> {44}; + 44 -> {45}; + 45 -> {46}; + 46 -> {47}; + 47 -> {48}; + 48 -> {49}; + 49 -> {52}; + 49 -> {50} [style=dotted]; + 50 -> {51} [style=dotted]; + 51 -> {52} [style=dotted]; -} + } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/returns.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/returns.dot index 217b0b2f6e1..84480f9d0b6 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/returns.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/returns.dot @@ -482,6 +482,7 @@ digraph returns_kt { 163 -> {164}; 164 -> {165}; 165 -> {166 170}; + 165 -> {170} [style=dashed]; 166 -> {167}; 167 -> {168}; 168 -> {169}; diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/lambdas/inPlaceLambdas.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/lambdas/inPlaceLambdas.dot index df6dc2199f0..1386cc91d05 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/lambdas/inPlaceLambdas.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/lambdas/inPlaceLambdas.dot @@ -89,6 +89,7 @@ digraph inPlaceLambdas_kt { 17 -> {18}; 18 -> {27}; 18 -> {20} [color=red]; + 18 -> {27} [style=dashed]; 19 -> {21} [color=red]; 20 -> {21} [color=green]; 21 -> {22}; @@ -136,6 +137,7 @@ digraph inPlaceLambdas_kt { 34 -> {35}; 35 -> {43}; 35 -> {37} [color=red]; + 35 -> {43} [style=dashed]; 36 -> {38} [color=red]; 37 -> {38} [color=green]; 38 -> {39}; @@ -212,6 +214,7 @@ digraph inPlaceLambdas_kt { 58 -> {59}; 59 -> {70}; 59 -> {61} [color=red]; + 59 -> {70} [style=dashed]; 60 -> {62} [color=red]; 61 -> {62} [color=green]; 62 -> {63}; diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/lambdas/lambdaInWhenBranch.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/lambdas/lambdaInWhenBranch.dot index 2c254d2fc95..5462e505c4f 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/lambdas/lambdaInWhenBranch.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/lambdas/lambdaInWhenBranch.dot @@ -24,227 +24,236 @@ digraph lambdaInWhenBranch_kt { 5 [label="Enter class SubClass1" style="filled" fillcolor=red]; subgraph cluster_3 { color=blue - 7 [label="Enter property" style="filled" fillcolor=red]; - 8 [label="Access variable R|/t|"]; - 9 [label="Exit property" style="filled" fillcolor=red]; + 6 [label="Part of class initialization"]; + 7 [label="Exit class SubClass1" style="filled" fillcolor=red]; } - 6 [label="Exit class SubClass1" style="filled" fillcolor=red]; - } - 5 -> {7} [color=green]; - 7 -> {8}; - 8 -> {9}; - 9 -> {6} [color=green]; + 5 -> {6} [color=green]; + 6 -> {7} [style=dotted]; + 6 -> {13} [color=green]; + 6 -> {13} [style=dashed]; - subgraph cluster_4 { - color=red - 10 [label="Enter function " style="filled" fillcolor=red]; - 11 [label="Delegated constructor call: super()"]; - 12 [label="Exit function " style="filled" fillcolor=red]; - } - 10 -> {11}; - 11 -> {12}; + subgraph cluster_4 { + color=red + 8 [label="Enter function " style="filled" fillcolor=red]; + 9 [label="Delegated constructor call: super()"]; + 10 [label="Exit function " style="filled" fillcolor=red]; + } + 8 -> {9}; + 9 -> {10}; - subgraph cluster_5 { - color=red - 13 [label="Enter function getter" style="filled" fillcolor=red]; - 14 [label="Exit function getter" style="filled" fillcolor=red]; - } - 13 -> {14}; + subgraph cluster_5 { + color=red + 11 [label="Enter function getter" style="filled" fillcolor=red]; + 12 [label="Exit function getter" style="filled" fillcolor=red]; + } + 11 -> {12}; - subgraph cluster_6 { - color=red - 15 [label="Enter function component1" style="filled" fillcolor=red]; - 16 [label="Exit function component1" style="filled" fillcolor=red]; - } - 15 -> {16}; + subgraph cluster_6 { + color=red + 13 [label="Enter property" style="filled" fillcolor=red]; + 14 [label="Access variable R|/t|"]; + 15 [label="Exit property" style="filled" fillcolor=red]; + } + 13 -> {14}; + 14 -> {15}; + 15 -> {7} [color=green]; + + subgraph cluster_7 { + color=red + 16 [label="Enter function component1" style="filled" fillcolor=red]; + 17 [label="Exit function component1" style="filled" fillcolor=red]; + } + 16 -> {17}; - subgraph cluster_7 { - color=red - 17 [label="Enter function copy" style="filled" fillcolor=red]; subgraph cluster_8 { - color=blue - 19 [label="Enter default value of t" style="filled" fillcolor=red]; - 20 [label="Access variable R|/SubClass1.t|"]; - 21 [label="Exit default value of t" style="filled" fillcolor=red]; + color=red + 18 [label="Enter function copy" style="filled" fillcolor=red]; + subgraph cluster_9 { + color=blue + 20 [label="Enter default value of t" style="filled" fillcolor=red]; + 21 [label="Access variable R|/SubClass1.t|"]; + 22 [label="Exit default value of t" style="filled" fillcolor=red]; + } + 19 [label="Exit function copy" style="filled" fillcolor=red]; } - 18 [label="Exit function copy" style="filled" fillcolor=red]; - } - 17 -> {19 18}; - 19 -> {20}; - 20 -> {21}; + 18 -> {20 19}; + 20 -> {21}; + 20 -> {20} [style=dashed]; + 21 -> {22}; - subgraph cluster_9 { - color=red - 22 [label="Enter class SubClass2" style="filled" fillcolor=red]; - 23 [label="Exit class SubClass2" style="filled" fillcolor=red]; - } - 22 -> {23} [color=green]; + subgraph cluster_10 { + color=red + 23 [label="Enter class SubClass2" style="filled" fillcolor=red]; + 24 [label="Exit class SubClass2" style="filled" fillcolor=red]; + } + 23 -> {24} [color=green]; - subgraph cluster_10 { - color=red - 24 [label="Enter function " style="filled" fillcolor=red]; - 25 [label="Delegated constructor call: super()"]; - 26 [label="Exit function " style="filled" fillcolor=red]; - } - 24 -> {25}; - 25 -> {26}; + subgraph cluster_11 { + color=red + 25 [label="Enter function " style="filled" fillcolor=red]; + 26 [label="Delegated constructor call: super()"]; + 27 [label="Exit function " style="filled" fillcolor=red]; + } + 25 -> {26}; + 26 -> {27}; - subgraph cluster_11 { - color=red - 27 [label="Enter function copy" style="filled" fillcolor=red]; - 28 [label="Exit function copy" style="filled" fillcolor=red]; - } - 27 -> {28}; + subgraph cluster_12 { + color=red + 28 [label="Enter function copy" style="filled" fillcolor=red]; + 29 [label="Exit function copy" style="filled" fillcolor=red]; + } + 28 -> {29}; - subgraph cluster_12 { - color=red - 29 [label="Enter function foo" style="filled" fillcolor=red]; subgraph cluster_13 { - color=blue - 30 [label="Enter block"]; + color=red + 30 [label="Enter function foo" style="filled" fillcolor=red]; subgraph cluster_14 { color=blue - 31 [label="Enter when"]; - 32 [label="Access variable R|/p|"]; + 31 [label="Enter block"]; subgraph cluster_15 { color=blue - 33 [label="Enter when branch condition "]; - 34 [label="Type operator: ($subj$ is R|SubClass1|)"]; - 35 [label="Exit when branch condition"]; - } - subgraph cluster_16 { - color=blue - 36 [label="Enter when branch condition "]; - 37 [label="Type operator: ($subj$ is R|SubClass2|)"]; - 38 [label="Exit when branch condition"]; - } - 39 [label="Enter when branch result"]; - subgraph cluster_17 { - color=blue - 40 [label="Enter block"]; - 41 [label="Const: String()"]; - 42 [label="Exit block"]; - } - 43 [label="Exit when branch result"]; - 44 [label="Enter when branch result"]; - subgraph cluster_18 { - color=blue - 45 [label="Enter block"]; - 46 [label="Const: String()"]; - 47 [label="Postponed enter to lambda"]; + 32 [label="Enter when"]; + 33 [label="Access variable R|/p|"]; + subgraph cluster_16 { + color=blue + 34 [label="Enter when branch condition "]; + 35 [label="Type operator: ($subj$ is R|SubClass1|)"]; + 36 [label="Exit when branch condition"]; + } + subgraph cluster_17 { + color=blue + 37 [label="Enter when branch condition "]; + 38 [label="Type operator: ($subj$ is R|SubClass2|)"]; + 39 [label="Exit when branch condition"]; + } + 40 [label="Enter when branch result"]; + subgraph cluster_18 { + color=blue + 41 [label="Enter block"]; + 42 [label="Const: String()"]; + 43 [label="Exit block"]; + } + 44 [label="Exit when branch result"]; + 45 [label="Enter when branch result"]; subgraph cluster_19 { color=blue - 78 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 46 [label="Enter block"]; + 47 [label="Const: String()"]; + 48 [label="Postponed enter to lambda"]; subgraph cluster_20 { color=blue - 79 [label="Enter block"]; - 80 [label="Access variable R|/it|"]; - 81 [label="Exit block"]; + 79 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + subgraph cluster_21 { + color=blue + 80 [label="Enter block"]; + 81 [label="Access variable R|/it|"]; + 82 [label="Exit block"]; + } + 83 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 82 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 49 [label="Postponed exit from lambda"]; + 50 [label="Function call: String().R|kotlin/let|(...)"]; + 51 [label="Exit block"]; } - 48 [label="Postponed exit from lambda"]; - 49 [label="Function call: String().R|kotlin/let|(...)"]; - 50 [label="Exit block"]; + 52 [label="Exit when branch result"]; + 53 [label="Exit when"]; } - 51 [label="Exit when branch result"]; - 52 [label="Exit when"]; - } - 53 [label="Access variable R|/p|"]; - 54 [label="Access variable #"]; - subgraph cluster_21 { - color=blue - 55 [label="Enter when"]; - 56 [label="Access variable R|/p|"]; + 54 [label="Access variable R|/p|"]; + 55 [label="Access variable #"]; subgraph cluster_22 { color=blue - 57 [label="Enter when branch condition "]; - 58 [label="Type operator: ($subj$ is R|SubClass1|)"]; - 59 [label="Exit when branch condition"]; + 56 [label="Enter when"]; + 57 [label="Access variable R|/p|"]; + subgraph cluster_23 { + color=blue + 58 [label="Enter when branch condition "]; + 59 [label="Type operator: ($subj$ is R|SubClass1|)"]; + 60 [label="Exit when branch condition"]; + } + subgraph cluster_24 { + color=blue + 61 [label="Enter when branch condition "]; + 62 [label="Type operator: ($subj$ is R|SubClass2|)"]; + 63 [label="Exit when branch condition"]; + } + 64 [label="Enter when branch result"]; + subgraph cluster_25 { + color=blue + 65 [label="Enter block"]; + 66 [label="Const: String(2)"]; + 67 [label="Exit block"]; + } + 68 [label="Exit when branch result"]; + 69 [label="Enter when branch result"]; + subgraph cluster_26 { + color=blue + 70 [label="Enter block"]; + 71 [label="Access variable R|/p|"]; + 72 [label="Access variable R|/SubClass1.t|"]; + 73 [label="Exit block"]; + } + 74 [label="Exit when branch result"]; + 75 [label="Exit when"]; } - subgraph cluster_23 { - color=blue - 60 [label="Enter when branch condition "]; - 61 [label="Type operator: ($subj$ is R|SubClass2|)"]; - 62 [label="Exit when branch condition"]; - } - 63 [label="Enter when branch result"]; - subgraph cluster_24 { - color=blue - 64 [label="Enter block"]; - 65 [label="Const: String(2)"]; - 66 [label="Exit block"]; - } - 67 [label="Exit when branch result"]; - 68 [label="Enter when branch result"]; - subgraph cluster_25 { - color=blue - 69 [label="Enter block"]; - 70 [label="Access variable R|/p|"]; - 71 [label="Access variable R|/SubClass1.t|"]; - 72 [label="Exit block"]; - } - 73 [label="Exit when branch result"]; - 74 [label="Exit when"]; + 76 [label="Access variable R|kotlin/String.length|"]; + 77 [label="Exit block"]; } - 75 [label="Access variable R|kotlin/String.length|"]; - 76 [label="Exit block"]; + 78 [label="Exit function foo" style="filled" fillcolor=red]; } - 77 [label="Exit function foo" style="filled" fillcolor=red]; - } - 29 -> {30}; - 30 -> {31}; - 31 -> {32}; - 32 -> {33}; - 33 -> {34}; - 34 -> {35}; - 35 -> {44 36}; - 36 -> {37}; - 37 -> {38}; - 38 -> {39}; - 39 -> {40}; - 40 -> {41}; - 41 -> {42}; - 42 -> {43}; - 43 -> {52}; - 44 -> {45}; - 45 -> {46}; - 46 -> {47}; - 47 -> {78}; - 47 -> {48} [color=red]; - 48 -> {49}; - 49 -> {50}; - 50 -> {51}; - 51 -> {52}; - 52 -> {53}; - 53 -> {54}; - 54 -> {55}; - 55 -> {56}; - 56 -> {57}; - 57 -> {58}; - 58 -> {59}; - 59 -> {68 60}; - 60 -> {61}; - 61 -> {62}; - 62 -> {63}; - 63 -> {64}; - 64 -> {65}; - 65 -> {66}; - 66 -> {67}; - 67 -> {74}; - 68 -> {69}; - 69 -> {70}; - 70 -> {71}; - 71 -> {72}; - 72 -> {73}; - 73 -> {74}; - 74 -> {75}; - 75 -> {76}; - 76 -> {77}; - 78 -> {79}; - 79 -> {80}; - 80 -> {81}; - 81 -> {82}; - 82 -> {48} [color=green]; + 30 -> {31}; + 31 -> {32}; + 32 -> {33}; + 33 -> {34}; + 34 -> {35}; + 35 -> {36}; + 36 -> {45 37}; + 37 -> {38}; + 38 -> {39}; + 39 -> {40}; + 40 -> {41}; + 41 -> {42}; + 42 -> {43}; + 43 -> {44}; + 44 -> {53}; + 45 -> {46}; + 46 -> {47}; + 47 -> {48}; + 48 -> {79}; + 48 -> {49} [color=red]; + 48 -> {79} [style=dashed]; + 49 -> {50}; + 50 -> {51}; + 51 -> {52}; + 52 -> {53}; + 53 -> {54}; + 54 -> {55}; + 55 -> {56}; + 56 -> {57}; + 57 -> {58}; + 58 -> {59}; + 59 -> {60}; + 60 -> {69 61}; + 61 -> {62}; + 62 -> {63}; + 63 -> {64}; + 64 -> {65}; + 65 -> {66}; + 66 -> {67}; + 67 -> {68}; + 68 -> {75}; + 69 -> {70}; + 70 -> {71}; + 71 -> {72}; + 72 -> {73}; + 73 -> {74}; + 74 -> {75}; + 75 -> {76}; + 76 -> {77}; + 77 -> {78}; + 79 -> {80}; + 80 -> {81}; + 81 -> {82}; + 82 -> {83}; + 83 -> {49} [color=green]; -} + } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers/implicitReceivers.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers/implicitReceivers.dot index 1c55864a3fa..32cbc91eb03 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers/implicitReceivers.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers/implicitReceivers.dot @@ -302,6 +302,7 @@ digraph implicitReceivers_kt { 82 -> {83}; 83 -> {89}; 83 -> {85} [color=red]; + 83 -> {89} [style=dashed]; 84 -> {86} [color=red]; 85 -> {86} [color=green]; 86 -> {87}; @@ -311,6 +312,7 @@ digraph implicitReceivers_kt { 91 -> {92}; 92 -> {97}; 92 -> {93} [color=red]; + 92 -> {97} [style=dashed]; 93 -> {94}; 94 -> {95}; 95 -> {96}; @@ -321,6 +323,7 @@ digraph implicitReceivers_kt { 99 -> {100}; 100 -> {109}; 100 -> {102} [color=red]; + 100 -> {109} [style=dashed]; 101 -> {103} [color=red]; 102 -> {103} [color=green]; 103 -> {104}; diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/assignSafeCall.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/assignSafeCall.dot index a61f277b5c0..8a7707438d1 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/assignSafeCall.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/assignSafeCall.dot @@ -8,420 +8,427 @@ digraph assignSafeCall_kt { 0 [label="Enter class A" style="filled" fillcolor=red]; subgraph cluster_1 { color=blue - 2 [label="Enter property" style="filled" fillcolor=red]; - 3 [label="Const: Int(1)"]; - 4 [label="Exit property" style="filled" fillcolor=red]; + 1 [label="Part of class initialization"]; + 2 [label="Exit class A" style="filled" fillcolor=red]; } - 1 [label="Exit class A" style="filled" fillcolor=red]; - } - 0 -> {2} [color=green]; - 2 -> {3}; - 3 -> {4}; - 4 -> {1} [color=green]; + 0 -> {1} [color=green]; + 1 -> {2} [style=dotted]; + 1 -> {15} [color=green]; + 1 -> {15} [style=dashed]; - subgraph cluster_2 { - color=red - 5 [label="Enter function " style="filled" fillcolor=red]; - 6 [label="Delegated constructor call: super()"]; - 7 [label="Exit function " style="filled" fillcolor=red]; - } - 5 -> {6}; - 6 -> {7}; - - subgraph cluster_3 { - color=red - 8 [label="Enter function foo" style="filled" fillcolor=red]; - subgraph cluster_4 { - color=blue - 9 [label="Enter block"]; - 10 [label="Const: Int(1)"]; - 11 [label="Jump: ^foo Int(1)"]; - 12 [label="Stub" style="filled" fillcolor=gray]; - 13 [label="Exit block" style="filled" fillcolor=gray]; + subgraph cluster_2 { + color=red + 3 [label="Enter function " style="filled" fillcolor=red]; + 4 [label="Delegated constructor call: super()"]; + 5 [label="Exit function " style="filled" fillcolor=red]; } - 14 [label="Exit function foo" style="filled" fillcolor=red]; - } - 8 -> {9}; - 9 -> {10}; - 10 -> {11}; - 11 -> {14}; - 11 -> {12} [style=dotted]; - 12 -> {13} [style=dotted]; - 13 -> {14} [style=dotted]; + 3 -> {4}; + 4 -> {5}; - subgraph cluster_5 { - color=red - 15 [label="Enter function getter" style="filled" fillcolor=red]; - 16 [label="Exit function getter" style="filled" fillcolor=red]; - } - 15 -> {16}; + subgraph cluster_3 { + color=red + 6 [label="Enter function foo" style="filled" fillcolor=red]; + subgraph cluster_4 { + color=blue + 7 [label="Enter block"]; + 8 [label="Const: Int(1)"]; + 9 [label="Jump: ^foo Int(1)"]; + 10 [label="Stub" style="filled" fillcolor=gray]; + 11 [label="Exit block" style="filled" fillcolor=gray]; + } + 12 [label="Exit function foo" style="filled" fillcolor=red]; + } + 6 -> {7}; + 7 -> {8}; + 8 -> {9}; + 9 -> {12}; + 9 -> {10} [style=dotted]; + 10 -> {11} [style=dotted]; + 11 -> {12} [style=dotted]; + + subgraph cluster_5 { + color=red + 13 [label="Enter function getter" style="filled" fillcolor=red]; + 14 [label="Exit function getter" style="filled" fillcolor=red]; + } + 13 -> {14}; + + subgraph cluster_6 { + color=red + 15 [label="Enter property" style="filled" fillcolor=red]; + 16 [label="Const: Int(1)"]; + 17 [label="Exit property" style="filled" fillcolor=red]; + } + 15 -> {16}; + 16 -> {17}; + 17 -> {2} [color=green]; - subgraph cluster_6 { - color=red - 17 [label="Enter function bar" style="filled" fillcolor=red]; subgraph cluster_7 { - color=blue - 18 [label="Enter block"]; - 19 [label="Exit block"]; + color=red + 18 [label="Enter function bar" style="filled" fillcolor=red]; + subgraph cluster_8 { + color=blue + 19 [label="Enter block"]; + 20 [label="Exit block"]; + } + 21 [label="Exit function bar" style="filled" fillcolor=red]; } - 20 [label="Exit function bar" style="filled" fillcolor=red]; - } - 17 -> {18}; - 18 -> {19}; - 19 -> {20}; + 18 -> {19}; + 19 -> {20}; + 20 -> {21}; - subgraph cluster_8 { - color=red - 21 [label="Enter function test_1" style="filled" fillcolor=red]; subgraph cluster_9 { - color=blue - 22 [label="Enter block"]; - 23 [label="Access variable R|/a|"]; - 24 [label="Enter safe call"]; - 25 [label="Access variable R|/A.x|"]; - 26 [label="Exit safe call"]; - 27 [label="Variable declaration: lval x: R|kotlin/Int?|"]; + color=red + 22 [label="Enter function test_1" style="filled" fillcolor=red]; subgraph cluster_10 { color=blue - 28 [label="Enter when"]; + 23 [label="Enter block"]; + 24 [label="Access variable R|/a|"]; + 25 [label="Enter safe call"]; + 26 [label="Access variable R|/A.x|"]; + 27 [label="Exit safe call"]; + 28 [label="Variable declaration: lval x: R|kotlin/Int?|"]; subgraph cluster_11 { color=blue - 29 [label="Enter when branch condition "]; - 30 [label="Access variable R|/x|"]; - 31 [label="Const: Null(null)"]; - 32 [label="Equality operator !="]; - 33 [label="Exit when branch condition"]; + 29 [label="Enter when"]; + subgraph cluster_12 { + color=blue + 30 [label="Enter when branch condition "]; + 31 [label="Access variable R|/x|"]; + 32 [label="Const: Null(null)"]; + 33 [label="Equality operator !="]; + 34 [label="Exit when branch condition"]; + } + 35 [label="Synthetic else branch"]; + 36 [label="Enter when branch result"]; + subgraph cluster_13 { + color=blue + 37 [label="Enter block"]; + 38 [label="Access variable R|/a|"]; + 39 [label="Function call: R|/a|.R|/A.bar|()"]; + 40 [label="Exit block"]; + } + 41 [label="Exit when branch result"]; + 42 [label="Exit when"]; } - 34 [label="Synthetic else branch"]; - 35 [label="Enter when branch result"]; - subgraph cluster_12 { - color=blue - 36 [label="Enter block"]; - 37 [label="Access variable R|/a|"]; - 38 [label="Function call: R|/a|.R|/A.bar|()"]; - 39 [label="Exit block"]; - } - 40 [label="Exit when branch result"]; - 41 [label="Exit when"]; + 43 [label="Exit block"]; } - 42 [label="Exit block"]; + 44 [label="Exit function test_1" style="filled" fillcolor=red]; } - 43 [label="Exit function test_1" style="filled" fillcolor=red]; - } - 21 -> {22}; - 22 -> {23}; - 23 -> {24 26}; - 24 -> {25}; - 25 -> {26}; - 26 -> {27}; - 27 -> {28}; - 28 -> {29}; - 29 -> {30}; - 30 -> {31}; - 31 -> {32}; - 32 -> {33}; - 33 -> {35 34}; - 34 -> {41}; - 35 -> {36}; - 36 -> {37}; - 37 -> {38}; - 38 -> {39}; - 39 -> {40}; - 40 -> {41}; - 41 -> {42}; - 42 -> {43}; + 22 -> {23}; + 23 -> {24}; + 24 -> {25 27}; + 25 -> {26}; + 26 -> {27}; + 27 -> {28}; + 28 -> {29}; + 29 -> {30}; + 30 -> {31}; + 31 -> {32}; + 32 -> {33}; + 33 -> {34}; + 34 -> {36 35}; + 35 -> {42}; + 36 -> {37}; + 37 -> {38}; + 38 -> {39}; + 39 -> {40}; + 40 -> {41}; + 41 -> {42}; + 42 -> {43}; + 43 -> {44}; - subgraph cluster_13 { - color=red - 44 [label="Enter function test_2" style="filled" fillcolor=red]; subgraph cluster_14 { - color=blue - 45 [label="Enter block"]; - 46 [label="Access variable R|/a|"]; - 47 [label="Enter safe call"]; - 48 [label="Function call: $subj$.R|/A.foo|()"]; - 49 [label="Exit safe call"]; - 50 [label="Variable declaration: lval x: R|kotlin/Int?|"]; + color=red + 45 [label="Enter function test_2" style="filled" fillcolor=red]; subgraph cluster_15 { color=blue - 51 [label="Enter when"]; + 46 [label="Enter block"]; + 47 [label="Access variable R|/a|"]; + 48 [label="Enter safe call"]; + 49 [label="Function call: $subj$.R|/A.foo|()"]; + 50 [label="Exit safe call"]; + 51 [label="Variable declaration: lval x: R|kotlin/Int?|"]; subgraph cluster_16 { color=blue - 52 [label="Enter when branch condition "]; - 53 [label="Access variable R|/x|"]; - 54 [label="Const: Null(null)"]; - 55 [label="Equality operator !="]; - 56 [label="Exit when branch condition"]; + 52 [label="Enter when"]; + subgraph cluster_17 { + color=blue + 53 [label="Enter when branch condition "]; + 54 [label="Access variable R|/x|"]; + 55 [label="Const: Null(null)"]; + 56 [label="Equality operator !="]; + 57 [label="Exit when branch condition"]; + } + 58 [label="Synthetic else branch"]; + 59 [label="Enter when branch result"]; + subgraph cluster_18 { + color=blue + 60 [label="Enter block"]; + 61 [label="Access variable R|/a|"]; + 62 [label="Function call: R|/a|.R|/A.bar|()"]; + 63 [label="Exit block"]; + } + 64 [label="Exit when branch result"]; + 65 [label="Exit when"]; } - 57 [label="Synthetic else branch"]; - 58 [label="Enter when branch result"]; - subgraph cluster_17 { - color=blue - 59 [label="Enter block"]; - 60 [label="Access variable R|/a|"]; - 61 [label="Function call: R|/a|.R|/A.bar|()"]; - 62 [label="Exit block"]; - } - 63 [label="Exit when branch result"]; - 64 [label="Exit when"]; + 66 [label="Exit block"]; } - 65 [label="Exit block"]; + 67 [label="Exit function test_2" style="filled" fillcolor=red]; } - 66 [label="Exit function test_2" style="filled" fillcolor=red]; - } - 44 -> {45}; - 45 -> {46}; - 46 -> {47 49}; - 47 -> {48}; - 48 -> {49}; - 49 -> {50}; - 50 -> {51}; - 51 -> {52}; - 52 -> {53}; - 53 -> {54}; - 54 -> {55}; - 55 -> {56}; - 56 -> {58 57}; - 57 -> {64}; - 58 -> {59}; - 59 -> {60}; - 60 -> {61}; - 61 -> {62}; - 62 -> {63}; - 63 -> {64}; - 64 -> {65}; - 65 -> {66}; + 45 -> {46}; + 46 -> {47}; + 47 -> {48 50}; + 48 -> {49}; + 49 -> {50}; + 50 -> {51}; + 51 -> {52}; + 52 -> {53}; + 53 -> {54}; + 54 -> {55}; + 55 -> {56}; + 56 -> {57}; + 57 -> {59 58}; + 58 -> {65}; + 59 -> {60}; + 60 -> {61}; + 61 -> {62}; + 62 -> {63}; + 63 -> {64}; + 64 -> {65}; + 65 -> {66}; + 66 -> {67}; - subgraph cluster_18 { - color=red - 67 [label="Enter function test_3" style="filled" fillcolor=red]; subgraph cluster_19 { - color=blue - 68 [label="Enter block"]; - 69 [label="Access variable R|/x|"]; - 70 [label="Type operator: (R|/x| as? R|A|)"]; - 71 [label="Exit lhs of ?:"]; - 72 [label="Enter rhs of ?:"]; - 73 [label="Jump: ^test_3 Unit"]; - 74 [label="Stub" style="filled" fillcolor=gray]; - 75 [label="Lhs of ?: is not null"]; - 76 [label="Exit ?:"]; - 77 [label="Variable declaration: lval a: R|A|"]; - 78 [label="Access variable R|/a|"]; - 79 [label="Function call: R|/a|.R|/A.foo|()"]; - 80 [label="Access variable R|/x|"]; - 81 [label="Function call: R|/x|.R|/A.foo|()"]; - 82 [label="Exit block"]; + color=red + 68 [label="Enter function test_3" style="filled" fillcolor=red]; + subgraph cluster_20 { + color=blue + 69 [label="Enter block"]; + 70 [label="Access variable R|/x|"]; + 71 [label="Type operator: (R|/x| as? R|A|)"]; + 72 [label="Exit lhs of ?:"]; + 73 [label="Enter rhs of ?:"]; + 74 [label="Jump: ^test_3 Unit"]; + 75 [label="Stub" style="filled" fillcolor=gray]; + 76 [label="Lhs of ?: is not null"]; + 77 [label="Exit ?:"]; + 78 [label="Variable declaration: lval a: R|A|"]; + 79 [label="Access variable R|/a|"]; + 80 [label="Function call: R|/a|.R|/A.foo|()"]; + 81 [label="Access variable R|/x|"]; + 82 [label="Function call: R|/x|.R|/A.foo|()"]; + 83 [label="Exit block"]; + } + 84 [label="Exit function test_3" style="filled" fillcolor=red]; } - 83 [label="Exit function test_3" style="filled" fillcolor=red]; - } - 67 -> {68}; - 68 -> {69}; - 69 -> {70}; - 70 -> {71}; - 71 -> {75 72}; - 72 -> {73}; - 73 -> {83}; - 73 -> {74} [style=dotted]; - 74 -> {76} [style=dotted]; - 75 -> {76}; - 76 -> {77}; - 77 -> {78}; - 78 -> {79}; - 79 -> {80}; - 80 -> {81}; - 81 -> {82}; - 82 -> {83}; + 68 -> {69}; + 69 -> {70}; + 70 -> {71}; + 71 -> {72}; + 72 -> {76 73}; + 73 -> {74}; + 74 -> {84}; + 74 -> {75} [style=dotted]; + 75 -> {77} [style=dotted]; + 76 -> {77}; + 77 -> {78}; + 78 -> {79}; + 79 -> {80}; + 80 -> {81}; + 81 -> {82}; + 82 -> {83}; + 83 -> {84}; - subgraph cluster_20 { - color=red - 84 [label="Enter class B" style="filled" fillcolor=red]; - 85 [label="Exit class B" style="filled" fillcolor=red]; - } - 84 -> {85} [color=green]; + subgraph cluster_21 { + color=red + 85 [label="Enter class B" style="filled" fillcolor=red]; + 86 [label="Exit class B" style="filled" fillcolor=red]; + } + 85 -> {86} [color=green]; - subgraph cluster_21 { - color=red - 86 [label="Enter function foo" style="filled" fillcolor=red]; - 87 [label="Exit function foo" style="filled" fillcolor=red]; - } - 86 -> {87}; + subgraph cluster_22 { + color=red + 87 [label="Enter function foo" style="filled" fillcolor=red]; + 88 [label="Exit function foo" style="filled" fillcolor=red]; + } + 87 -> {88}; - subgraph cluster_22 { - color=red - 88 [label="Enter function getter" style="filled" fillcolor=red]; - 89 [label="Exit function getter" style="filled" fillcolor=red]; - } - 88 -> {89}; + subgraph cluster_23 { + color=red + 89 [label="Enter function getter" style="filled" fillcolor=red]; + 90 [label="Exit function getter" style="filled" fillcolor=red]; + } + 89 -> {90}; - subgraph cluster_23 { - color=red - 90 [label="Enter function bar" style="filled" fillcolor=red]; - 91 [label="Exit function bar" style="filled" fillcolor=red]; - } - 90 -> {91}; + subgraph cluster_24 { + color=red + 91 [label="Enter function bar" style="filled" fillcolor=red]; + 92 [label="Exit function bar" style="filled" fillcolor=red]; + } + 91 -> {92}; - subgraph cluster_24 { - color=red - 92 [label="Enter function test_1" style="filled" fillcolor=red]; subgraph cluster_25 { - color=blue - 93 [label="Enter block"]; - 94 [label="Access variable R|/a|"]; - 95 [label="Enter safe call"]; - 96 [label="Access variable R|/B.x|"]; - 97 [label="Exit safe call"]; - 98 [label="Variable declaration: lval x: R|kotlin/Int?|"]; + color=red + 93 [label="Enter function test_1" style="filled" fillcolor=red]; subgraph cluster_26 { color=blue - 99 [label="Enter when"]; + 94 [label="Enter block"]; + 95 [label="Access variable R|/a|"]; + 96 [label="Enter safe call"]; + 97 [label="Access variable R|/B.x|"]; + 98 [label="Exit safe call"]; + 99 [label="Variable declaration: lval x: R|kotlin/Int?|"]; subgraph cluster_27 { color=blue - 100 [label="Enter when branch condition "]; - 101 [label="Access variable R|/x|"]; - 102 [label="Const: Null(null)"]; - 103 [label="Equality operator !="]; - 104 [label="Exit when branch condition"]; + 100 [label="Enter when"]; + subgraph cluster_28 { + color=blue + 101 [label="Enter when branch condition "]; + 102 [label="Access variable R|/x|"]; + 103 [label="Const: Null(null)"]; + 104 [label="Equality operator !="]; + 105 [label="Exit when branch condition"]; + } + 106 [label="Synthetic else branch"]; + 107 [label="Enter when branch result"]; + subgraph cluster_29 { + color=blue + 108 [label="Enter block"]; + 109 [label="Access variable R|/a|"]; + 110 [label="Function call: R|/a|.R|/B.bar|()"]; + 111 [label="Exit block"]; + } + 112 [label="Exit when branch result"]; + 113 [label="Exit when"]; } - 105 [label="Synthetic else branch"]; - 106 [label="Enter when branch result"]; - subgraph cluster_28 { - color=blue - 107 [label="Enter block"]; - 108 [label="Access variable R|/a|"]; - 109 [label="Function call: R|/a|.R|/B.bar|()"]; - 110 [label="Exit block"]; - } - 111 [label="Exit when branch result"]; - 112 [label="Exit when"]; + 114 [label="Exit block"]; } - 113 [label="Exit block"]; + 115 [label="Exit function test_1" style="filled" fillcolor=red]; } - 114 [label="Exit function test_1" style="filled" fillcolor=red]; - } - 92 -> {93}; - 93 -> {94}; - 94 -> {95 97}; - 95 -> {96}; - 96 -> {97}; - 97 -> {98}; - 98 -> {99}; - 99 -> {100}; - 100 -> {101}; - 101 -> {102}; - 102 -> {103}; - 103 -> {104}; - 104 -> {106 105}; - 105 -> {112}; - 106 -> {107}; - 107 -> {108}; - 108 -> {109}; - 109 -> {110}; - 110 -> {111}; - 111 -> {112}; - 112 -> {113}; - 113 -> {114}; + 93 -> {94}; + 94 -> {95}; + 95 -> {96 98}; + 96 -> {97}; + 97 -> {98}; + 98 -> {99}; + 99 -> {100}; + 100 -> {101}; + 101 -> {102}; + 102 -> {103}; + 103 -> {104}; + 104 -> {105}; + 105 -> {107 106}; + 106 -> {113}; + 107 -> {108}; + 108 -> {109}; + 109 -> {110}; + 110 -> {111}; + 111 -> {112}; + 112 -> {113}; + 113 -> {114}; + 114 -> {115}; - subgraph cluster_29 { - color=red - 115 [label="Enter function test_2" style="filled" fillcolor=red]; subgraph cluster_30 { - color=blue - 116 [label="Enter block"]; - 117 [label="Access variable R|/a|"]; - 118 [label="Enter safe call"]; - 119 [label="Function call: $subj$.R|/B.foo|()"]; - 120 [label="Exit safe call"]; - 121 [label="Variable declaration: lval x: R|kotlin/Int?|"]; + color=red + 116 [label="Enter function test_2" style="filled" fillcolor=red]; subgraph cluster_31 { color=blue - 122 [label="Enter when"]; + 117 [label="Enter block"]; + 118 [label="Access variable R|/a|"]; + 119 [label="Enter safe call"]; + 120 [label="Function call: $subj$.R|/B.foo|()"]; + 121 [label="Exit safe call"]; + 122 [label="Variable declaration: lval x: R|kotlin/Int?|"]; subgraph cluster_32 { color=blue - 123 [label="Enter when branch condition "]; - 124 [label="Access variable R|/x|"]; - 125 [label="Const: Null(null)"]; - 126 [label="Equality operator !="]; - 127 [label="Exit when branch condition"]; + 123 [label="Enter when"]; + subgraph cluster_33 { + color=blue + 124 [label="Enter when branch condition "]; + 125 [label="Access variable R|/x|"]; + 126 [label="Const: Null(null)"]; + 127 [label="Equality operator !="]; + 128 [label="Exit when branch condition"]; + } + 129 [label="Synthetic else branch"]; + 130 [label="Enter when branch result"]; + subgraph cluster_34 { + color=blue + 131 [label="Enter block"]; + 132 [label="Access variable R|/a|"]; + 133 [label="Function call: R|/a|.R|/B.bar|()"]; + 134 [label="Exit block"]; + } + 135 [label="Exit when branch result"]; + 136 [label="Exit when"]; } - 128 [label="Synthetic else branch"]; - 129 [label="Enter when branch result"]; - subgraph cluster_33 { - color=blue - 130 [label="Enter block"]; - 131 [label="Access variable R|/a|"]; - 132 [label="Function call: R|/a|.R|/B.bar|()"]; - 133 [label="Exit block"]; - } - 134 [label="Exit when branch result"]; - 135 [label="Exit when"]; + 137 [label="Exit block"]; } - 136 [label="Exit block"]; + 138 [label="Exit function test_2" style="filled" fillcolor=red]; } - 137 [label="Exit function test_2" style="filled" fillcolor=red]; - } - 115 -> {116}; - 116 -> {117}; - 117 -> {118 120}; - 118 -> {119}; - 119 -> {120}; - 120 -> {121}; - 121 -> {122}; - 122 -> {123}; - 123 -> {124}; - 124 -> {125}; - 125 -> {126}; - 126 -> {127}; - 127 -> {129 128}; - 128 -> {135}; - 129 -> {130}; - 130 -> {131}; - 131 -> {132}; - 132 -> {133}; - 133 -> {134}; - 134 -> {135}; - 135 -> {136}; - 136 -> {137}; + 116 -> {117}; + 117 -> {118}; + 118 -> {119 121}; + 119 -> {120}; + 120 -> {121}; + 121 -> {122}; + 122 -> {123}; + 123 -> {124}; + 124 -> {125}; + 125 -> {126}; + 126 -> {127}; + 127 -> {128}; + 128 -> {130 129}; + 129 -> {136}; + 130 -> {131}; + 131 -> {132}; + 132 -> {133}; + 133 -> {134}; + 134 -> {135}; + 135 -> {136}; + 136 -> {137}; + 137 -> {138}; - subgraph cluster_34 { - color=red - 138 [label="Enter function test_3" style="filled" fillcolor=red]; subgraph cluster_35 { - color=blue - 139 [label="Enter block"]; - 140 [label="Access variable R|/x|"]; - 141 [label="Type operator: (R|/x| as? R|B|)"]; - 142 [label="Exit lhs of ?:"]; - 143 [label="Enter rhs of ?:"]; - 144 [label="Jump: ^test_3 Unit"]; - 145 [label="Stub" style="filled" fillcolor=gray]; - 146 [label="Lhs of ?: is not null"]; - 147 [label="Exit ?:"]; - 148 [label="Variable declaration: lval a: R|B|"]; - 149 [label="Access variable R|/a|"]; - 150 [label="Function call: R|/a|.R|/B.foo|()"]; - 151 [label="Access variable R|/x|"]; - 152 [label="Function call: R|/x|.R|/B.foo|()"]; - 153 [label="Exit block"]; + color=red + 139 [label="Enter function test_3" style="filled" fillcolor=red]; + subgraph cluster_36 { + color=blue + 140 [label="Enter block"]; + 141 [label="Access variable R|/x|"]; + 142 [label="Type operator: (R|/x| as? R|B|)"]; + 143 [label="Exit lhs of ?:"]; + 144 [label="Enter rhs of ?:"]; + 145 [label="Jump: ^test_3 Unit"]; + 146 [label="Stub" style="filled" fillcolor=gray]; + 147 [label="Lhs of ?: is not null"]; + 148 [label="Exit ?:"]; + 149 [label="Variable declaration: lval a: R|B|"]; + 150 [label="Access variable R|/a|"]; + 151 [label="Function call: R|/a|.R|/B.foo|()"]; + 152 [label="Access variable R|/x|"]; + 153 [label="Function call: R|/x|.R|/B.foo|()"]; + 154 [label="Exit block"]; + } + 155 [label="Exit function test_3" style="filled" fillcolor=red]; } - 154 [label="Exit function test_3" style="filled" fillcolor=red]; - } - 138 -> {139}; - 139 -> {140}; - 140 -> {141}; - 141 -> {142}; - 142 -> {146 143}; - 143 -> {144}; - 144 -> {154}; - 144 -> {145} [style=dotted]; - 145 -> {147} [style=dotted]; - 146 -> {147}; - 147 -> {148}; - 148 -> {149}; - 149 -> {150}; - 150 -> {151}; - 151 -> {152}; - 152 -> {153}; - 153 -> {154}; + 139 -> {140}; + 140 -> {141}; + 141 -> {142}; + 142 -> {143}; + 143 -> {147 144}; + 144 -> {145}; + 145 -> {155}; + 145 -> {146} [style=dotted]; + 146 -> {148} [style=dotted]; + 147 -> {148}; + 148 -> {149}; + 149 -> {150}; + 150 -> {151}; + 151 -> {152}; + 152 -> {153}; + 153 -> {154}; + 154 -> {155}; -} + } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCalls.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCalls.dot index e51055dc071..eafca769e04 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCalls.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCalls.dot @@ -181,6 +181,7 @@ digraph safeCalls_kt { 55 -> {56 60}; 56 -> {57}; 57 -> {58 65}; + 57 -> {65} [style=dashed]; 58 -> {59}; 59 -> {60}; 60 -> {61}; @@ -282,6 +283,7 @@ digraph safeCalls_kt { 91 -> {92}; 92 -> {107}; 92 -> {94} [color=red]; + 92 -> {107} [style=dashed]; 93 -> {95} [style=dotted]; 94 -> {95} [style=dotted]; 95 -> {106 96} [style=dotted]; diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartCastInInit.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartCastInInit.dot index 7c59a1f669a..65571ef78d5 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartCastInInit.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartCastInInit.dot @@ -52,44 +52,51 @@ digraph smartCastInInit_kt { 14 [label="Enter class Main" style="filled" fillcolor=red]; subgraph cluster_6 { color=blue - 16 [label="Enter init block" style="filled" fillcolor=red]; - subgraph cluster_7 { - color=blue - 17 [label="Enter block"]; - 18 [label="Function call: R|/s|()"]; - 19 [label="Assignment: R|/Main.x|"]; - 20 [label="Access variable R|/Main.x|"]; - 21 [label="Function call: this@R|/Main|.R|/Main.x|.R|/S.foo|()"]; - 22 [label="Exit block"]; - } - 23 [label="Exit init block" style="filled" fillcolor=red]; + 15 [label="Part of class initialization"]; + 16 [label="Exit class Main" style="filled" fillcolor=red]; } - 15 [label="Exit class Main" style="filled" fillcolor=red]; - } - 14 -> {16} [color=green]; - 16 -> {17}; - 17 -> {18}; - 18 -> {19}; - 19 -> {20}; - 20 -> {21}; - 21 -> {22}; - 22 -> {23}; - 23 -> {15} [color=green]; + 14 -> {15} [color=green]; + 15 -> {16} [style=dotted]; + 15 -> {22} [color=green]; + 15 -> {22} [style=dashed]; - subgraph cluster_8 { - color=red - 24 [label="Enter function " style="filled" fillcolor=red]; - 25 [label="Delegated constructor call: super()"]; - 26 [label="Exit function " style="filled" fillcolor=red]; - } - 24 -> {25}; - 25 -> {26}; + subgraph cluster_7 { + color=red + 17 [label="Enter function " style="filled" fillcolor=red]; + 18 [label="Delegated constructor call: super()"]; + 19 [label="Exit function " style="filled" fillcolor=red]; + } + 17 -> {18}; + 18 -> {19}; - subgraph cluster_9 { - color=red - 27 [label="Enter function getter" style="filled" fillcolor=red]; - 28 [label="Exit function getter" style="filled" fillcolor=red]; - } - 27 -> {28}; + subgraph cluster_8 { + color=red + 20 [label="Enter function getter" style="filled" fillcolor=red]; + 21 [label="Exit function getter" style="filled" fillcolor=red]; + } + 20 -> {21}; -} + subgraph cluster_9 { + color=red + 22 [label="Enter init block" style="filled" fillcolor=red]; + subgraph cluster_10 { + color=blue + 23 [label="Enter block"]; + 24 [label="Function call: R|/s|()"]; + 25 [label="Assignment: R|/Main.x|"]; + 26 [label="Access variable R|/Main.x|"]; + 27 [label="Function call: this@R|/Main|.R|/Main.x|.R|/S.foo|()"]; + 28 [label="Exit block"]; + } + 29 [label="Exit init block" style="filled" fillcolor=red]; + } + 22 -> {23}; + 23 -> {24}; + 24 -> {25}; + 25 -> {26}; + 26 -> {27}; + 27 -> {28}; + 28 -> {29}; + 29 -> {16} [color=green]; + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToNothing.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToNothing.dot index c3fc860c8ac..4290dcff5fd 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToNothing.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToNothing.dot @@ -119,189 +119,204 @@ digraph smartcastToNothing_kt { 38 [label="Enter class A" style="filled" fillcolor=red]; subgraph cluster_11 { color=blue - 40 [label="Enter property" style="filled" fillcolor=red]; - 41 [label="Const: Int(1)"]; - 42 [label="Exit property" style="filled" fillcolor=red]; - } - subgraph cluster_12 { - color=blue - 43 [label="Enter property" style="filled" fillcolor=red]; - 44 [label="Const: Boolean(true)"]; - 45 [label="Exit property" style="filled" fillcolor=red]; - } - 39 [label="Exit class A" style="filled" fillcolor=red]; - } - 38 -> {40} [color=green]; - 40 -> {41}; - 41 -> {42}; - 42 -> {43} [color=green]; - 43 -> {44}; - 44 -> {45}; - 45 -> {39} [color=green]; - - subgraph cluster_13 { - color=red - 46 [label="Enter function " style="filled" fillcolor=red]; - 47 [label="Delegated constructor call: super()"]; - 48 [label="Exit function " style="filled" fillcolor=red]; - } - 46 -> {47}; - 47 -> {48}; - - subgraph cluster_14 { - color=red - 49 [label="Enter function getter" style="filled" fillcolor=red]; - 50 [label="Exit function getter" style="filled" fillcolor=red]; - } - 49 -> {50}; - - subgraph cluster_15 { - color=red - 51 [label="Enter function getter" style="filled" fillcolor=red]; - 52 [label="Exit function getter" style="filled" fillcolor=red]; - } - 51 -> {52}; - - subgraph cluster_16 { - color=red - 53 [label="Enter function test_0" style="filled" fillcolor=red]; - subgraph cluster_17 { - color=blue - 54 [label="Enter block"]; - 55 [label="Const: Null(null)"]; - 56 [label="Variable declaration: lvar s: R|A?|"]; - 57 [label="Access variable R|/results|"]; - 58 [label="Function call: R|/results|.R|FakeOverride|>|()"]; - 59 [label="Variable declaration: lval : R|kotlin/collections/Iterator|"]; - subgraph cluster_18 { + 39 [label="Part of class initialization"]; + subgraph cluster_12 { color=blue - 60 [label="Enter while loop"]; + 40 [label="Part of class initialization"]; + 41 [label="Exit class A" style="filled" fillcolor=red]; + } + 38 -> {39} [color=green]; + 39 -> {40} [style=dotted]; + 39 -> {47} [color=green]; + 39 -> {47} [style=dashed]; + 40 -> {41} [style=dotted]; + 40 -> {52} [color=green]; + 40 -> {52} [style=dashed]; + + subgraph cluster_13 { + color=red + 42 [label="Enter function " style="filled" fillcolor=red]; + 43 [label="Delegated constructor call: super()"]; + 44 [label="Exit function " style="filled" fillcolor=red]; + } + 42 -> {43}; + 43 -> {44}; + + subgraph cluster_14 { + color=red + 45 [label="Enter function getter" style="filled" fillcolor=red]; + 46 [label="Exit function getter" style="filled" fillcolor=red]; + } + 45 -> {46}; + + subgraph cluster_15 { + color=red + 47 [label="Enter property" style="filled" fillcolor=red]; + 48 [label="Const: Int(1)"]; + 49 [label="Exit property" style="filled" fillcolor=red]; + } + 47 -> {48}; + 48 -> {49}; + 49 -> {40} [color=green]; + + subgraph cluster_16 { + color=red + 50 [label="Enter function getter" style="filled" fillcolor=red]; + 51 [label="Exit function getter" style="filled" fillcolor=red]; + } + 50 -> {51}; + + subgraph cluster_17 { + color=red + 52 [label="Enter property" style="filled" fillcolor=red]; + 53 [label="Const: Boolean(true)"]; + 54 [label="Exit property" style="filled" fillcolor=red]; + } + 52 -> {53}; + 53 -> {54}; + 54 -> {41} [color=green]; + + subgraph cluster_18 { + color=red + 55 [label="Enter function test_0" style="filled" fillcolor=red]; subgraph cluster_19 { color=blue - 61 [label="Enter loop condition"]; - 62 [label="Access variable R|/|"]; - 63 [label="Function call: R|/|.R|kotlin/collections/Iterator.hasNext|()"]; - 64 [label="Exit loop condition"]; - } - subgraph cluster_20 { - color=blue - 65 [label="Enter loop block"]; - subgraph cluster_21 { + 56 [label="Enter block"]; + 57 [label="Const: Null(null)"]; + 58 [label="Variable declaration: lvar s: R|A?|"]; + 59 [label="Access variable R|/results|"]; + 60 [label="Function call: R|/results|.R|FakeOverride|>|()"]; + 61 [label="Variable declaration: lval : R|kotlin/collections/Iterator|"]; + subgraph cluster_20 { color=blue - 66 [label="Enter block"]; - 67 [label="Access variable R|/|"]; - 68 [label="Function call: R|/|.R|FakeOverride|()"]; - 69 [label="Stub" style="filled" fillcolor=gray]; - 70 [label="Variable declaration: lval result: R|kotlin/Nothing|" style="filled" fillcolor=gray]; - 71 [label="Access variable R|/result|" style="filled" fillcolor=gray]; - 72 [label="Stub" style="filled" fillcolor=gray]; - 73 [label="Assignment: R|/s|" style="filled" fillcolor=gray]; + 62 [label="Enter while loop"]; + subgraph cluster_21 { + color=blue + 63 [label="Enter loop condition"]; + 64 [label="Access variable R|/|"]; + 65 [label="Function call: R|/|.R|kotlin/collections/Iterator.hasNext|()"]; + 66 [label="Exit loop condition"]; + } subgraph cluster_22 { color=blue - 74 [label="Enter when" style="filled" fillcolor=gray]; + 67 [label="Enter loop block"]; subgraph cluster_23 { color=blue - 75 [label="Enter when branch condition " style="filled" fillcolor=gray]; - 76 [label="Access variable R|/result|" style="filled" fillcolor=gray]; - 77 [label="Stub" style="filled" fillcolor=gray]; - 78 [label="Access variable #" style="filled" fillcolor=gray]; - 79 [label="Exit when branch condition" style="filled" fillcolor=gray]; + 68 [label="Enter block"]; + 69 [label="Access variable R|/|"]; + 70 [label="Function call: R|/|.R|FakeOverride|()"]; + 71 [label="Stub" style="filled" fillcolor=gray]; + 72 [label="Variable declaration: lval result: R|kotlin/Nothing|" style="filled" fillcolor=gray]; + 73 [label="Access variable R|/result|" style="filled" fillcolor=gray]; + 74 [label="Stub" style="filled" fillcolor=gray]; + 75 [label="Assignment: R|/s|" style="filled" fillcolor=gray]; + subgraph cluster_24 { + color=blue + 76 [label="Enter when" style="filled" fillcolor=gray]; + subgraph cluster_25 { + color=blue + 77 [label="Enter when branch condition " style="filled" fillcolor=gray]; + 78 [label="Access variable R|/result|" style="filled" fillcolor=gray]; + 79 [label="Stub" style="filled" fillcolor=gray]; + 80 [label="Access variable #" style="filled" fillcolor=gray]; + 81 [label="Exit when branch condition" style="filled" fillcolor=gray]; + } + 82 [label="Synthetic else branch" style="filled" fillcolor=gray]; + 83 [label="Enter when branch result" style="filled" fillcolor=gray]; + subgraph cluster_26 { + color=blue + 84 [label="Enter block" style="filled" fillcolor=gray]; + 85 [label="Jump: break@@@[R|/|.R|kotlin/collections/Iterator.hasNext|()] " style="filled" fillcolor=gray]; + 86 [label="Stub" style="filled" fillcolor=gray]; + 87 [label="Exit block" style="filled" fillcolor=gray]; + } + 88 [label="Exit when branch result" style="filled" fillcolor=gray]; + 89 [label="Exit when" style="filled" fillcolor=gray]; + } + 90 [label="Exit block" style="filled" fillcolor=gray]; } - 80 [label="Synthetic else branch" style="filled" fillcolor=gray]; - 81 [label="Enter when branch result" style="filled" fillcolor=gray]; - subgraph cluster_24 { - color=blue - 82 [label="Enter block" style="filled" fillcolor=gray]; - 83 [label="Jump: break@@@[R|/|.R|kotlin/collections/Iterator.hasNext|()] " style="filled" fillcolor=gray]; - 84 [label="Stub" style="filled" fillcolor=gray]; - 85 [label="Exit block" style="filled" fillcolor=gray]; - } - 86 [label="Exit when branch result" style="filled" fillcolor=gray]; - 87 [label="Exit when" style="filled" fillcolor=gray]; + 91 [label="Exit loop block" style="filled" fillcolor=gray]; } - 88 [label="Exit block" style="filled" fillcolor=gray]; + 92 [label="Exit whileloop"]; } - 89 [label="Exit loop block" style="filled" fillcolor=gray]; + 93 [label="Access variable R|/s|"]; + 94 [label="Enter safe call"]; + 95 [label="Postponed enter to lambda"]; + subgraph cluster_27 { + color=blue + 102 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + subgraph cluster_28 { + color=blue + 103 [label="Enter block"]; + 104 [label="Access variable R|/it|"]; + 105 [label="Access variable R|/A.a|"]; + 106 [label="Exit block"]; + } + 107 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + } + 96 [label="Call arguments union" style="filled" fillcolor=yellow]; + 97 [label="Postponed exit from lambda"]; + 98 [label="Function call: $subj$.R|kotlin/let|(...)"]; + 99 [label="Exit safe call"]; + 100 [label="Exit block"]; } - 90 [label="Exit whileloop"]; + 101 [label="Exit function test_0" style="filled" fillcolor=red]; } - 91 [label="Access variable R|/s|"]; - 92 [label="Enter safe call"]; - 93 [label="Postponed enter to lambda"]; - subgraph cluster_25 { - color=blue - 100 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; - subgraph cluster_26 { - color=blue - 101 [label="Enter block"]; - 102 [label="Access variable R|/it|"]; - 103 [label="Access variable R|/A.a|"]; - 104 [label="Exit block"]; - } - 105 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; - } - 94 [label="Call arguments union" style="filled" fillcolor=yellow]; - 95 [label="Postponed exit from lambda"]; - 96 [label="Function call: $subj$.R|kotlin/let|(...)"]; - 97 [label="Exit safe call"]; - 98 [label="Exit block"]; - } - 99 [label="Exit function test_0" style="filled" fillcolor=red]; - } - 53 -> {54}; - 54 -> {55}; - 55 -> {56}; - 56 -> {57}; - 57 -> {58}; - 58 -> {59}; - 59 -> {60}; - 60 -> {61}; - 61 -> {62}; - 62 -> {63}; - 63 -> {64}; - 64 -> {90 65}; - 65 -> {66}; - 66 -> {67}; - 67 -> {68}; - 68 -> {99}; - 68 -> {69} [style=dotted]; - 69 -> {70} [style=dotted]; - 70 -> {71} [style=dotted]; - 71 -> {99 72} [style=dotted]; - 72 -> {73} [style=dotted]; - 73 -> {74} [style=dotted]; - 74 -> {75} [style=dotted]; - 75 -> {76} [style=dotted]; - 76 -> {99 77} [style=dotted]; - 77 -> {78} [style=dotted]; - 78 -> {79} [style=dotted]; - 79 -> {81 80} [style=dotted]; - 80 -> {87} [style=dotted]; - 81 -> {82} [style=dotted]; - 82 -> {83} [style=dotted]; - 83 -> {90 84} [style=dotted]; - 84 -> {85} [style=dotted]; - 85 -> {86} [style=dotted]; - 86 -> {87} [style=dotted]; - 87 -> {88} [style=dotted]; - 88 -> {89} [style=dotted]; - 89 -> {61} [color=green style=dotted]; - 90 -> {91}; - 91 -> {92 97}; - 92 -> {93}; - 93 -> {100}; - 93 -> {95} [color=red]; - 94 -> {96} [color=red]; - 95 -> {96} [color=green]; - 96 -> {97}; - 97 -> {98}; - 98 -> {99}; - 100 -> {101}; - 101 -> {102}; - 102 -> {103}; - 103 -> {104}; - 104 -> {105}; - 105 -> {94} [color=red]; - 105 -> {95} [color=green]; + 55 -> {56}; + 56 -> {57}; + 57 -> {58}; + 58 -> {59}; + 59 -> {60}; + 60 -> {61}; + 61 -> {62}; + 62 -> {63}; + 63 -> {64}; + 64 -> {65}; + 65 -> {66}; + 66 -> {92 67}; + 67 -> {68}; + 68 -> {69}; + 69 -> {70}; + 70 -> {101}; + 70 -> {71} [style=dotted]; + 71 -> {72} [style=dotted]; + 72 -> {73} [style=dotted]; + 73 -> {101 74} [style=dotted]; + 74 -> {75} [style=dotted]; + 75 -> {76} [style=dotted]; + 76 -> {77} [style=dotted]; + 77 -> {78} [style=dotted]; + 78 -> {101 79} [style=dotted]; + 79 -> {80} [style=dotted]; + 80 -> {81} [style=dotted]; + 81 -> {83 82} [style=dotted]; + 82 -> {89} [style=dotted]; + 83 -> {84} [style=dotted]; + 84 -> {85} [style=dotted]; + 85 -> {92 86} [style=dotted]; + 86 -> {87} [style=dotted]; + 87 -> {88} [style=dotted]; + 88 -> {89} [style=dotted]; + 89 -> {90} [style=dotted]; + 90 -> {91} [style=dotted]; + 91 -> {63} [color=green style=dotted]; + 92 -> {93}; + 93 -> {94 99}; + 94 -> {95}; + 95 -> {102}; + 95 -> {97} [color=red]; + 95 -> {102} [style=dashed]; + 96 -> {98} [color=red]; + 97 -> {98} [color=green]; + 98 -> {99}; + 99 -> {100}; + 100 -> {101}; + 102 -> {103}; + 103 -> {104}; + 104 -> {105}; + 105 -> {106}; + 106 -> {107}; + 107 -> {96} [color=red]; + 107 -> {97} [color=green]; -} + } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/stability/overridenOpenVal.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/stability/overridenOpenVal.dot index 3d23f4808f7..889db36bb9e 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/stability/overridenOpenVal.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/stability/overridenOpenVal.dot @@ -8,151 +8,158 @@ digraph overridenOpenVal_kt { 0 [label="Enter class A" style="filled" fillcolor=red]; subgraph cluster_1 { color=blue - 2 [label="Enter property" style="filled" fillcolor=red]; - 3 [label="Access variable R|/x|"]; - 4 [label="Exit property" style="filled" fillcolor=red]; + 1 [label="Part of class initialization"]; + 2 [label="Exit class A" style="filled" fillcolor=red]; } - 1 [label="Exit class A" style="filled" fillcolor=red]; - } - 0 -> {2} [color=green]; - 2 -> {3}; - 3 -> {4}; - 4 -> {1} [color=green]; + 0 -> {1} [color=green]; + 1 -> {2} [style=dotted]; + 1 -> {8} [color=green]; + 1 -> {8} [style=dashed]; - subgraph cluster_2 { - color=red - 5 [label="Enter function " style="filled" fillcolor=red]; - 6 [label="Delegated constructor call: super()"]; - 7 [label="Exit function " style="filled" fillcolor=red]; - } - 5 -> {6}; - 6 -> {7}; + subgraph cluster_2 { + color=red + 3 [label="Enter function " style="filled" fillcolor=red]; + 4 [label="Delegated constructor call: super()"]; + 5 [label="Exit function " style="filled" fillcolor=red]; + } + 3 -> {4}; + 4 -> {5}; - subgraph cluster_3 { - color=red - 8 [label="Enter function getter" style="filled" fillcolor=red]; - 9 [label="Exit function getter" style="filled" fillcolor=red]; - } - 8 -> {9}; + subgraph cluster_3 { + color=red + 6 [label="Enter function getter" style="filled" fillcolor=red]; + 7 [label="Exit function getter" style="filled" fillcolor=red]; + } + 6 -> {7}; - subgraph cluster_4 { - color=red - 10 [label="Enter class B" style="filled" fillcolor=red]; - 11 [label="Exit class B" style="filled" fillcolor=red]; - } - 10 -> {11} [color=green]; + subgraph cluster_4 { + color=red + 8 [label="Enter property" style="filled" fillcolor=red]; + 9 [label="Access variable R|/x|"]; + 10 [label="Exit property" style="filled" fillcolor=red]; + } + 8 -> {9}; + 9 -> {10}; + 10 -> {2} [color=green]; - subgraph cluster_5 { - color=red - 12 [label="Enter function " style="filled" fillcolor=red]; - 13 [label="Access variable R|/x|"]; - 14 [label="Delegated constructor call: super(...)"]; - 15 [label="Exit function " style="filled" fillcolor=red]; - } - 12 -> {13}; - 13 -> {14}; - 14 -> {15}; + subgraph cluster_5 { + color=red + 11 [label="Enter class B" style="filled" fillcolor=red]; + 12 [label="Exit class B" style="filled" fillcolor=red]; + } + 11 -> {12} [color=green]; + + subgraph cluster_6 { + color=red + 13 [label="Enter function " style="filled" fillcolor=red]; + 14 [label="Access variable R|/x|"]; + 15 [label="Delegated constructor call: super(...)"]; + 16 [label="Exit function " style="filled" fillcolor=red]; + } + 13 -> {14}; + 14 -> {15}; + 15 -> {16}; - subgraph cluster_6 { - color=red - 16 [label="Enter function test_1" style="filled" fillcolor=red]; subgraph cluster_7 { - color=blue - 17 [label="Enter block"]; + color=red + 17 [label="Enter function test_1" style="filled" fillcolor=red]; subgraph cluster_8 { color=blue - 18 [label="Enter when"]; + 18 [label="Enter block"]; subgraph cluster_9 { color=blue - 19 [label="Enter when branch condition "]; - 20 [label="Access variable R|/A.x|"]; - 21 [label="Type operator: (this@R|/B|.R|/A.x| is R|kotlin/String|)"]; - 22 [label="Exit when branch condition"]; + 19 [label="Enter when"]; + subgraph cluster_10 { + color=blue + 20 [label="Enter when branch condition "]; + 21 [label="Access variable R|/A.x|"]; + 22 [label="Type operator: (this@R|/B|.R|/A.x| is R|kotlin/String|)"]; + 23 [label="Exit when branch condition"]; + } + 24 [label="Synthetic else branch"]; + 25 [label="Enter when branch result"]; + subgraph cluster_11 { + color=blue + 26 [label="Enter block"]; + 27 [label="Access variable R|/A.x|"]; + 28 [label="Access variable R|kotlin/String.length|"]; + 29 [label="Exit block"]; + } + 30 [label="Exit when branch result"]; + 31 [label="Exit when"]; } - 23 [label="Synthetic else branch"]; - 24 [label="Enter when branch result"]; - subgraph cluster_10 { - color=blue - 25 [label="Enter block"]; - 26 [label="Access variable R|/A.x|"]; - 27 [label="Access variable R|kotlin/String.length|"]; - 28 [label="Exit block"]; - } - 29 [label="Exit when branch result"]; - 30 [label="Exit when"]; + 32 [label="Exit block"]; } - 31 [label="Exit block"]; + 33 [label="Exit function test_1" style="filled" fillcolor=red]; } - 32 [label="Exit function test_1" style="filled" fillcolor=red]; - } - 16 -> {17}; - 17 -> {18}; - 18 -> {19}; - 19 -> {20}; - 20 -> {21}; - 21 -> {22}; - 22 -> {24 23}; - 23 -> {30}; - 24 -> {25}; - 25 -> {26}; - 26 -> {27}; - 27 -> {28}; - 28 -> {29}; - 29 -> {30}; - 30 -> {31}; - 31 -> {32}; + 17 -> {18}; + 18 -> {19}; + 19 -> {20}; + 20 -> {21}; + 21 -> {22}; + 22 -> {23}; + 23 -> {25 24}; + 24 -> {31}; + 25 -> {26}; + 26 -> {27}; + 27 -> {28}; + 28 -> {29}; + 29 -> {30}; + 30 -> {31}; + 31 -> {32}; + 32 -> {33}; - subgraph cluster_11 { - color=red - 33 [label="Enter function test_2" style="filled" fillcolor=red]; subgraph cluster_12 { - color=blue - 34 [label="Enter block"]; + color=red + 34 [label="Enter function test_2" style="filled" fillcolor=red]; subgraph cluster_13 { color=blue - 35 [label="Enter when"]; + 35 [label="Enter block"]; subgraph cluster_14 { color=blue - 36 [label="Enter when branch condition "]; - 37 [label="Access variable R|/b|"]; - 38 [label="Access variable R|/A.x|"]; - 39 [label="Type operator: (R|/b|.R|/A.x| is R|kotlin/String|)"]; - 40 [label="Exit when branch condition"]; + 36 [label="Enter when"]; + subgraph cluster_15 { + color=blue + 37 [label="Enter when branch condition "]; + 38 [label="Access variable R|/b|"]; + 39 [label="Access variable R|/A.x|"]; + 40 [label="Type operator: (R|/b|.R|/A.x| is R|kotlin/String|)"]; + 41 [label="Exit when branch condition"]; + } + 42 [label="Synthetic else branch"]; + 43 [label="Enter when branch result"]; + subgraph cluster_16 { + color=blue + 44 [label="Enter block"]; + 45 [label="Access variable R|/b|"]; + 46 [label="Access variable R|/A.x|"]; + 47 [label="Access variable R|kotlin/String.length|"]; + 48 [label="Exit block"]; + } + 49 [label="Exit when branch result"]; + 50 [label="Exit when"]; } - 41 [label="Synthetic else branch"]; - 42 [label="Enter when branch result"]; - subgraph cluster_15 { - color=blue - 43 [label="Enter block"]; - 44 [label="Access variable R|/b|"]; - 45 [label="Access variable R|/A.x|"]; - 46 [label="Access variable R|kotlin/String.length|"]; - 47 [label="Exit block"]; - } - 48 [label="Exit when branch result"]; - 49 [label="Exit when"]; + 51 [label="Exit block"]; } - 50 [label="Exit block"]; + 52 [label="Exit function test_2" style="filled" fillcolor=red]; } - 51 [label="Exit function test_2" style="filled" fillcolor=red]; - } - 33 -> {34}; - 34 -> {35}; - 35 -> {36}; - 36 -> {37}; - 37 -> {38}; - 38 -> {39}; - 39 -> {40}; - 40 -> {42 41}; - 41 -> {49}; - 42 -> {43}; - 43 -> {44}; - 44 -> {45}; - 45 -> {46}; - 46 -> {47}; - 47 -> {48}; - 48 -> {49}; - 49 -> {50}; - 50 -> {51}; + 34 -> {35}; + 35 -> {36}; + 36 -> {37}; + 37 -> {38}; + 38 -> {39}; + 39 -> {40}; + 40 -> {41}; + 41 -> {43 42}; + 42 -> {50}; + 43 -> {44}; + 44 -> {45}; + 45 -> {46}; + 46 -> {47}; + 47 -> {48}; + 48 -> {49}; + 49 -> {50}; + 50 -> {51}; + 51 -> {52}; -} + } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/complexPostponedCfg.dot b/compiler/fir/analysis-tests/testData/resolveWithStdlib/complexPostponedCfg.dot index 2f2df4159f7..79adab4b991 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/complexPostponedCfg.dot +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/complexPostponedCfg.dot @@ -92,6 +92,7 @@ digraph complexPostponedCfg_kt { 8 -> {9}; 9 -> {19}; 9 -> {11} [color=red]; + 9 -> {19} [style=dashed]; 10 -> {12} [color=red]; 11 -> {12} [color=green]; 12 -> {13}; @@ -105,6 +106,7 @@ digraph complexPostponedCfg_kt { 20 -> {21}; 21 -> {26}; 21 -> {22} [color=red]; + 21 -> {26} [style=dashed]; 22 -> {23}; 23 -> {24}; 24 -> {25}; @@ -119,6 +121,7 @@ digraph complexPostponedCfg_kt { 32 -> {33}; 33 -> {39}; 33 -> {35} [color=red]; + 33 -> {39} [style=dashed]; 34 -> {36} [color=red]; 35 -> {36} [color=green]; 36 -> {37}; diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromLibrary/callsInPlace.dot b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromLibrary/callsInPlace.dot index 6da39bb8cfd..0d37c8f05bb 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromLibrary/callsInPlace.dot +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromLibrary/callsInPlace.dot @@ -37,6 +37,7 @@ digraph callsInPlace_kt { 2 -> {3}; 3 -> {11}; 3 -> {5} [color=red]; + 3 -> {11} [style=dashed]; 4 -> {6} [color=red]; 5 -> {6} [color=green]; 6 -> {7}; @@ -81,6 +82,7 @@ digraph callsInPlace_kt { 19 -> {20}; 20 -> {25}; 20 -> {21} [color=red]; + 20 -> {25} [style=dashed]; 21 -> {22}; 22 -> {23}; 23 -> {24}; @@ -120,6 +122,7 @@ digraph callsInPlace_kt { 31 -> {32}; 32 -> {38}; 32 -> {33} [color=red]; + 32 -> {38} [style=dashed]; 33 -> {34}; 34 -> {35}; 35 -> {36}; @@ -166,6 +169,7 @@ digraph callsInPlace_kt { 45 -> {46}; 46 -> {52}; 46 -> {48} [color=red]; + 46 -> {52} [style=dashed]; 47 -> {49} [color=red]; 48 -> {49} [color=green]; 49 -> {50}; @@ -216,6 +220,7 @@ digraph callsInPlace_kt { 63 -> {64}; 64 -> {70}; 64 -> {66} [color=red]; + 64 -> {70} [style=dashed]; 65 -> {67} [color=red]; 66 -> {67} [color=green]; 67 -> {68}; @@ -290,9 +295,11 @@ digraph callsInPlace_kt { 86 -> {87}; 87 -> {94}; 87 -> {88} [color=red]; + 87 -> {94} [style=dashed]; 88 -> {89}; 89 -> {99}; 89 -> {90} [color=red]; + 89 -> {99} [style=dashed]; 90 -> {91}; 91 -> {92}; 92 -> {93}; @@ -350,9 +357,11 @@ digraph callsInPlace_kt { 105 -> {106}; 106 -> {113}; 106 -> {107} [color=red]; + 106 -> {113} [style=dashed]; 107 -> {108}; 108 -> {118}; 108 -> {109} [color=red]; + 108 -> {118} [style=dashed]; 109 -> {110}; 110 -> {111}; 111 -> {112}; @@ -412,6 +421,7 @@ digraph callsInPlace_kt { 128 -> {129}; 129 -> {130}; 130 -> {131 135}; + 130 -> {135} [style=dashed]; 131 -> {132}; 132 -> {133}; 133 -> {134}; diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/callsInPlace/atLeastOnce.dot b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/callsInPlace/atLeastOnce.dot index f9daa3fdf6f..d435bda7efa 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/callsInPlace/atLeastOnce.dot +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/callsInPlace/atLeastOnce.dot @@ -68,6 +68,7 @@ digraph atLeastOnce_kt { 12 -> {13}; 13 -> {20}; 13 -> {14} [color=red]; + 13 -> {20} [style=dashed]; 14 -> {15}; 15 -> {16}; 16 -> {17}; @@ -114,6 +115,7 @@ digraph atLeastOnce_kt { 28 -> {29}; 29 -> {36}; 29 -> {30} [color=red]; + 29 -> {36} [style=dashed]; 30 -> {31}; 31 -> {32}; 32 -> {33}; diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/callsInPlace/atMostOnce.dot b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/callsInPlace/atMostOnce.dot index 5d935068d66..dadc62125ea 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/callsInPlace/atMostOnce.dot +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/callsInPlace/atMostOnce.dot @@ -68,6 +68,7 @@ digraph atMostOnce_kt { 12 -> {13}; 13 -> {20}; 13 -> {14} [color=red]; + 13 -> {20} [style=dashed]; 14 -> {15}; 15 -> {16}; 16 -> {17}; @@ -113,6 +114,7 @@ digraph atMostOnce_kt { 28 -> {29}; 29 -> {36}; 29 -> {30} [color=red]; + 29 -> {36} [style=dashed]; 30 -> {31}; 31 -> {32}; 32 -> {33}; diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/callsInPlace/exactlyOnce.dot b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/callsInPlace/exactlyOnce.dot index 991b6f6c673..b8c8e5b902b 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/callsInPlace/exactlyOnce.dot +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/callsInPlace/exactlyOnce.dot @@ -69,6 +69,7 @@ digraph exactlyOnce_kt { 12 -> {13}; 13 -> {21}; 13 -> {15} [color=red]; + 13 -> {21} [style=dashed]; 14 -> {16} [color=red]; 15 -> {16} [color=green]; 16 -> {17}; @@ -117,6 +118,7 @@ digraph exactlyOnce_kt { 29 -> {30}; 30 -> {38}; 30 -> {32} [color=red]; + 30 -> {38} [style=dashed]; 31 -> {33} [color=red]; 32 -> {33} [color=green]; 33 -> {34}; diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/callsInPlace/unknown.dot b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/callsInPlace/unknown.dot index e79a3991202..f2323c89cb8 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/callsInPlace/unknown.dot +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/callsInPlace/unknown.dot @@ -68,6 +68,7 @@ digraph unknown_kt { 12 -> {13}; 13 -> {20}; 13 -> {14} [color=red]; + 13 -> {20} [style=dashed]; 14 -> {15}; 15 -> {16}; 16 -> {17}; @@ -114,6 +115,7 @@ digraph unknown_kt { 28 -> {29}; 29 -> {36}; 29 -> {30} [color=red]; + 29 -> {36} [style=dashed]; 30 -> {31}; 31 -> {32}; 32 -> {33}; diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateWithAnonymousObject.dot b/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateWithAnonymousObject.dot index bef18d1b7d8..f603d6d2ce5 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateWithAnonymousObject.dot +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateWithAnonymousObject.dot @@ -77,162 +77,173 @@ digraph delegateWithAnonymousObject_kt { 22 [label="Enter class IssuesListUserProfile" style="filled" fillcolor=red]; subgraph cluster_9 { color=blue - 39 [label="Enter class " style="filled" fillcolor=red]; - 40 [label="Exit class " style="filled" fillcolor=red]; + 23 [label="Part of class initialization"]; + 24 [label="Exit class IssuesListUserProfile" style="filled" fillcolor=red]; } + 22 -> {23} [color=green]; + 23 -> {24} [style=dotted]; + 23 -> {71} [color=green]; + 23 -> {71} [style=dashed]; + subgraph cluster_10 { - color=blue - 24 [label="Enter property" style="filled" fillcolor=red]; - 25 [label="Postponed enter to lambda"]; - 26 [label="Postponed exit from lambda"]; - 27 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|(...)"]; - 28 [label="Access variable this@R|/IssuesListUserProfile|"]; - 29 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|(...).#(...)"]; - 30 [label="Postponed enter to lambda"]; - subgraph cluster_11 { + color=red + 25 [label="Enter function " style="filled" fillcolor=red]; + 26 [label="Delegated constructor call: super|>()"]; + 27 [label="Exit function " style="filled" fillcolor=red]; + } + 25 -> {26}; + 26 -> {27}; + + subgraph cluster_11 { + color=red + 35 [label="Enter function " style="filled" fillcolor=red]; + 36 [label="Delegated constructor call: super()"]; + 37 [label="Exit function " style="filled" fillcolor=red]; + } + 35 -> {36}; + 36 -> {37}; + + subgraph cluster_12 { + color=red + 38 [label="Enter function getValue" style="filled" fillcolor=red]; + subgraph cluster_13 { color=blue - 34 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; - subgraph cluster_12 { - color=blue - 35 [label="Enter block"]; - 36 [label="Exit anonymous object"]; - 37 [label="Exit block"]; - } - 38 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 39 [label="Enter block"]; + 40 [label="Function call: R|/IssueListView.IssueListView|()"]; + 41 [label="Jump: ^getValue R|/IssueListView.IssueListView|()"]; + 42 [label="Stub" style="filled" fillcolor=gray]; + 43 [label="Exit block" style="filled" fillcolor=gray]; } - 31 [label="Postponed exit from lambda"]; - 32 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|(...)"]; - 33 [label="Exit property" style="filled" fillcolor=red]; + 44 [label="Exit function getValue" style="filled" fillcolor=red]; } - 23 [label="Exit class IssuesListUserProfile" style="filled" fillcolor=red]; - } - 22 -> {24} [color=green]; - 24 -> {25}; - 25 -> {26}; - 26 -> {27}; - 27 -> {28}; - 28 -> {29}; - 29 -> {30}; - 30 -> {31 34}; - 31 -> {32}; - 32 -> {33}; - 33 -> {23} [color=green]; - 34 -> {35}; - 35 -> {36}; - 35 -> {44 47 54} [color=red]; - 36 -> {37}; - 37 -> {38}; - 39 -> {40} [color=green]; + 38 -> {39}; + 39 -> {40}; + 40 -> {41}; + 41 -> {44}; + 41 -> {42} [style=dotted]; + 42 -> {43} [style=dotted]; + 43 -> {44} [style=dotted]; - subgraph cluster_13 { - color=red - 41 [label="Enter function " style="filled" fillcolor=red]; - 42 [label="Delegated constructor call: super|>()"]; - 43 [label="Exit function " style="filled" fillcolor=red]; - } - 41 -> {42}; - 42 -> {43}; + subgraph cluster_14 { + color=red + 45 [label="Enter function setValue" style="filled" fillcolor=red]; + subgraph cluster_15 { + color=blue + 46 [label="Enter block"]; + 47 [label="Function call: R|/IssueListView.IssueListView|()"]; + 48 [label="Access variable R|/value|"]; + 49 [label="Function call: R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(...)"]; + 50 [label="Jump: ^setValue R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(R|/value|)"]; + 51 [label="Stub" style="filled" fillcolor=gray]; + 52 [label="Exit block" style="filled" fillcolor=gray]; + } + 53 [label="Exit function setValue" style="filled" fillcolor=red]; + } + 45 -> {46}; + 46 -> {47}; + 47 -> {48}; + 48 -> {49}; + 49 -> {50}; + 50 -> {53}; + 50 -> {51} [style=dotted]; + 51 -> {52} [style=dotted]; + 52 -> {53} [style=dotted]; - subgraph cluster_14 { - color=red - 44 [label="Enter function " style="filled" fillcolor=red]; - 45 [label="Delegated constructor call: super()"]; - 46 [label="Exit function " style="filled" fillcolor=red]; - } - 44 -> {45}; - 45 -> {46}; - - subgraph cluster_15 { - color=red - 47 [label="Enter function getValue" style="filled" fillcolor=red]; subgraph cluster_16 { - color=blue - 48 [label="Enter block"]; - 49 [label="Function call: R|/IssueListView.IssueListView|()"]; - 50 [label="Jump: ^getValue R|/IssueListView.IssueListView|()"]; - 51 [label="Stub" style="filled" fillcolor=gray]; - 52 [label="Exit block" style="filled" fillcolor=gray]; + color=red + 54 [label="Enter function getter" style="filled" fillcolor=red]; + subgraph cluster_17 { + color=blue + 55 [label="Enter block"]; + 56 [label="Access variable D|/IssuesListUserProfile.issueListView|"]; + 57 [label="Access variable this@R|/IssuesListUserProfile|"]; + 58 [label="Function call: this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|FakeOverride|(...)"]; + 59 [label="Jump: ^ this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|FakeOverride|(this@R|/IssuesListUserProfile|, ::R|/IssuesListUserProfile.issueListView|)"]; + 60 [label="Stub" style="filled" fillcolor=gray]; + 61 [label="Exit block" style="filled" fillcolor=gray]; + } + 62 [label="Exit function getter" style="filled" fillcolor=red]; } - 53 [label="Exit function getValue" style="filled" fillcolor=red]; - } - 47 -> {48}; - 48 -> {49}; - 49 -> {50}; - 50 -> {53}; - 50 -> {51} [style=dotted]; - 51 -> {52} [style=dotted]; - 52 -> {53} [style=dotted]; + 54 -> {55}; + 55 -> {56}; + 56 -> {57}; + 57 -> {58}; + 58 -> {59}; + 59 -> {62}; + 59 -> {60} [style=dotted]; + 60 -> {61} [style=dotted]; + 61 -> {62} [style=dotted]; - subgraph cluster_17 { - color=red - 54 [label="Enter function setValue" style="filled" fillcolor=red]; subgraph cluster_18 { - color=blue - 55 [label="Enter block"]; - 56 [label="Function call: R|/IssueListView.IssueListView|()"]; - 57 [label="Access variable R|/value|"]; - 58 [label="Function call: R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(...)"]; - 59 [label="Jump: ^setValue R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(R|/value|)"]; - 60 [label="Stub" style="filled" fillcolor=gray]; - 61 [label="Exit block" style="filled" fillcolor=gray]; + color=red + 63 [label="Enter function setter" style="filled" fillcolor=red]; + subgraph cluster_19 { + color=blue + 64 [label="Enter block"]; + 65 [label="Access variable D|/IssuesListUserProfile.issueListView|"]; + 66 [label="Access variable this@R|/IssuesListUserProfile|"]; + 67 [label="Access variable R|/issueListView|"]; + 68 [label="Function call: this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|FakeOverride|(...)"]; + 69 [label="Exit block"]; + } + 70 [label="Exit function setter" style="filled" fillcolor=red]; } - 62 [label="Exit function setValue" style="filled" fillcolor=red]; - } - 54 -> {55}; - 55 -> {56}; - 56 -> {57}; - 57 -> {58}; - 58 -> {59}; - 59 -> {62}; - 59 -> {60} [style=dotted]; - 60 -> {61} [style=dotted]; - 61 -> {62} [style=dotted]; + 63 -> {64}; + 64 -> {65}; + 65 -> {66}; + 66 -> {67}; + 67 -> {68}; + 68 -> {69}; + 69 -> {70}; - subgraph cluster_19 { - color=red - 63 [label="Enter function getter" style="filled" fillcolor=red]; subgraph cluster_20 { - color=blue - 64 [label="Enter block"]; - 65 [label="Access variable D|/IssuesListUserProfile.issueListView|"]; - 66 [label="Access variable this@R|/IssuesListUserProfile|"]; - 67 [label="Function call: this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|FakeOverride|(...)"]; - 68 [label="Jump: ^ this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|FakeOverride|(this@R|/IssuesListUserProfile|, ::R|/IssuesListUserProfile.issueListView|)"]; - 69 [label="Stub" style="filled" fillcolor=gray]; - 70 [label="Exit block" style="filled" fillcolor=gray]; - } - 71 [label="Exit function getter" style="filled" fillcolor=red]; - } - 63 -> {64}; - 64 -> {65}; - 65 -> {66}; - 66 -> {67}; - 67 -> {68}; - 68 -> {71}; - 68 -> {69} [style=dotted]; - 69 -> {70} [style=dotted]; - 70 -> {71} [style=dotted]; - - subgraph cluster_21 { - color=red - 72 [label="Enter function setter" style="filled" fillcolor=red]; - subgraph cluster_22 { - color=blue - 73 [label="Enter block"]; - 74 [label="Access variable D|/IssuesListUserProfile.issueListView|"]; + color=red + 71 [label="Enter property" style="filled" fillcolor=red]; + 72 [label="Postponed enter to lambda"]; + 73 [label="Postponed exit from lambda"]; + 74 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|(...)"]; 75 [label="Access variable this@R|/IssuesListUserProfile|"]; - 76 [label="Access variable R|/issueListView|"]; - 77 [label="Function call: this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|FakeOverride|(...)"]; - 78 [label="Exit block"]; + 76 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|(...).#(...)"]; + 77 [label="Postponed enter to lambda"]; + subgraph cluster_21 { + color=blue + 28 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + subgraph cluster_22 { + color=blue + 29 [label="Enter block"]; + 30 [label="Exit anonymous object"]; + 31 [label="Exit block"]; + } + 32 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + } + subgraph cluster_23 { + color=blue + 33 [label="Enter class " style="filled" fillcolor=red]; + 34 [label="Exit class " style="filled" fillcolor=red]; + } + 78 [label="Postponed exit from lambda"]; + 79 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|(...)"]; + 80 [label="Exit property" style="filled" fillcolor=red]; } - 79 [label="Exit function setter" style="filled" fillcolor=red]; - } - 72 -> {73}; - 73 -> {74}; - 74 -> {75}; - 75 -> {76}; - 76 -> {77}; - 77 -> {78}; - 78 -> {79}; + 71 -> {72}; + 72 -> {73}; + 72 -> {} [style=dashed]; + 73 -> {74}; + 74 -> {75}; + 75 -> {76}; + 76 -> {77}; + 77 -> {78 28}; + 77 -> {28} [style=dashed]; + 78 -> {79}; + 79 -> {80}; + 80 -> {24} [color=green]; + 28 -> {29}; + 29 -> {30}; + 29 -> {35 38 45} [color=red]; + 30 -> {31}; + 30 -> {35 38 45 33} [color=green]; + 30 -> {35 38 45 33} [style=dashed]; + 31 -> {32}; + 33 -> {34} [color=green]; -} + } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.dot b/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.dot index 8a4bbd79dbb..c86705eaf13 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.dot +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.dot @@ -39,6 +39,7 @@ digraph plusAssignWithLambdaInRhs_kt { 5 -> {6}; 6 -> {11}; 6 -> {7} [color=red]; + 6 -> {11} [style=dashed]; 7 -> {8}; 8 -> {9}; 9 -> {10}; @@ -54,107 +55,116 @@ digraph plusAssignWithLambdaInRhs_kt { 16 [label="Enter class A" style="filled" fillcolor=red]; subgraph cluster_5 { color=blue - 18 [label="Enter property" style="filled" fillcolor=red]; - 19 [label="Access variable R|/executor|"]; - 20 [label="Exit property" style="filled" fillcolor=red]; + 17 [label="Part of class initialization"]; + 18 [label="Exit class A" style="filled" fillcolor=red]; } - 17 [label="Exit class A" style="filled" fillcolor=red]; - } - 16 -> {18} [color=green]; - 18 -> {19}; - 19 -> {20}; - 20 -> {17} [color=green]; + 16 -> {17} [color=green]; + 17 -> {18} [style=dotted]; + 17 -> {24} [color=green]; + 17 -> {24} [style=dashed]; - subgraph cluster_6 { - color=red - 21 [label="Enter function " style="filled" fillcolor=red]; - 22 [label="Delegated constructor call: super()"]; - 23 [label="Exit function " style="filled" fillcolor=red]; - } - 21 -> {22}; - 22 -> {23}; + subgraph cluster_6 { + color=red + 19 [label="Enter function " style="filled" fillcolor=red]; + 20 [label="Delegated constructor call: super()"]; + 21 [label="Exit function " style="filled" fillcolor=red]; + } + 19 -> {20}; + 20 -> {21}; - subgraph cluster_7 { - color=red - 24 [label="Enter function getter" style="filled" fillcolor=red]; - 25 [label="Exit function getter" style="filled" fillcolor=red]; - } - 24 -> {25}; + subgraph cluster_7 { + color=red + 22 [label="Enter function getter" style="filled" fillcolor=red]; + 23 [label="Exit function getter" style="filled" fillcolor=red]; + } + 22 -> {23}; + + subgraph cluster_8 { + color=red + 24 [label="Enter property" style="filled" fillcolor=red]; + 25 [label="Access variable R|/executor|"]; + 26 [label="Exit property" style="filled" fillcolor=red]; + } + 24 -> {25}; + 25 -> {26}; + 26 -> {18} [color=green]; - subgraph cluster_8 { - color=red - 26 [label="Enter function postpone" style="filled" fillcolor=red]; subgraph cluster_9 { - color=blue - 27 [label="Enter block"]; - 28 [label="Function call: R|kotlin/collections/mutableListOf| kotlin/Unit|>()"]; - 29 [label="Variable declaration: lval queue: R|kotlin/collections/MutableList>|"]; - 30 [label="Postponed enter to lambda"]; + color=red + 27 [label="Enter function postpone" style="filled" fillcolor=red]; subgraph cluster_10 { color=blue - 37 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 28 [label="Enter block"]; + 29 [label="Function call: R|kotlin/collections/mutableListOf| kotlin/Unit|>()"]; + 30 [label="Variable declaration: lval queue: R|kotlin/collections/MutableList>|"]; + 31 [label="Postponed enter to lambda"]; subgraph cluster_11 { color=blue - 38 [label="Enter block"]; - 39 [label="Access variable R|/queue|"]; - 40 [label="Postponed enter to lambda"]; + 38 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; subgraph cluster_12 { color=blue - 45 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 39 [label="Enter block"]; + 40 [label="Access variable R|/queue|"]; + 41 [label="Postponed enter to lambda"]; subgraph cluster_13 { color=blue - 46 [label="Enter block"]; - 47 [label="Function call: R|/computation|.R|FakeOverride|()"]; - 48 [label="Function call: R|/resolve|.R|FakeOverride|(...)"]; - 49 [label="Exit block"]; + 46 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + subgraph cluster_14 { + color=blue + 47 [label="Enter block"]; + 48 [label="Function call: R|/computation|.R|FakeOverride|()"]; + 49 [label="Function call: R|/resolve|.R|FakeOverride|(...)"]; + 50 [label="Exit block"]; + } + 51 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 50 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 42 [label="Postponed exit from lambda"]; + 43 [label="Function call: R|/queue|.R|kotlin/collections/plusAssign| kotlin/Unit|>(...)"]; + 44 [label="Exit block"]; } - 41 [label="Postponed exit from lambda"]; - 42 [label="Function call: R|/queue|.R|kotlin/collections/plusAssign| kotlin/Unit|>(...)"]; - 43 [label="Exit block"]; + 45 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 44 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; - } - 31 [label="Postponed exit from lambda"]; - 32 [label="Function call: R|/A.A|(...)"]; - 33 [label="Jump: ^postpone R|/A.A|( = A@fun (resolve: R|(T) -> kotlin/Unit|): R|kotlin/Unit| { + 32 [label="Postponed exit from lambda"]; + 33 [label="Function call: R|/A.A|(...)"]; + 34 [label="Jump: ^postpone R|/A.A|( = A@fun (resolve: R|(T) -> kotlin/Unit|): R|kotlin/Unit| { R|/queue|.R|kotlin/collections/plusAssign| kotlin/Unit|>(A@fun (): R|kotlin/Unit| { R|/resolve|.R|FakeOverride|(R|/computation|.R|FakeOverride|()) } ) } )"]; - 34 [label="Stub" style="filled" fillcolor=gray]; - 35 [label="Exit block" style="filled" fillcolor=gray]; + 35 [label="Stub" style="filled" fillcolor=gray]; + 36 [label="Exit block" style="filled" fillcolor=gray]; + } + 37 [label="Exit function postpone" style="filled" fillcolor=red]; } - 36 [label="Exit function postpone" style="filled" fillcolor=red]; - } - 26 -> {27}; - 27 -> {28}; - 28 -> {29}; - 29 -> {30}; - 30 -> {31 37}; - 31 -> {32}; - 32 -> {33}; - 33 -> {36}; - 33 -> {34} [style=dotted]; - 34 -> {35} [style=dotted]; - 35 -> {36} [style=dotted]; - 37 -> {38}; - 38 -> {39}; - 39 -> {40}; - 40 -> {45}; - 40 -> {41} [color=red]; - 41 -> {42}; - 42 -> {43}; - 43 -> {44}; - 45 -> {50 46}; - 46 -> {47}; - 47 -> {48}; - 48 -> {49}; - 49 -> {50}; - 50 -> {41} [color=green]; - 50 -> {45} [color=green style=dashed]; + 27 -> {28}; + 28 -> {29}; + 29 -> {30}; + 30 -> {31}; + 31 -> {32 38}; + 31 -> {38} [style=dashed]; + 32 -> {33}; + 33 -> {34}; + 34 -> {37}; + 34 -> {35} [style=dotted]; + 35 -> {36} [style=dotted]; + 36 -> {37} [style=dotted]; + 38 -> {39}; + 39 -> {40}; + 40 -> {41}; + 41 -> {46}; + 41 -> {42} [color=red]; + 41 -> {46} [style=dashed]; + 42 -> {43}; + 43 -> {44}; + 44 -> {45}; + 46 -> {51 47}; + 47 -> {48}; + 48 -> {49}; + 49 -> {50}; + 50 -> {51}; + 51 -> {42} [color=green]; + 51 -> {46} [color=green style=dashed]; -} + } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/initialization/fromLocalMembers.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/initialization/fromLocalMembers.kt new file mode 100644 index 00000000000..b6af8bd6979 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/initialization/fromLocalMembers.kt @@ -0,0 +1,46 @@ +fun test1() { + val x: Int + + fun func() { + x = 0 + } + + println(x) +} + + +fun test2() { + val x: Int + val y: Int + + object { + init { + x = 0 + } + + fun localFunc() { + y = 0 + } + } + + println(x) + println(x) +} + +fun test3() { + val x: Int + val y: Int + + class A { + init { + x = 0 + } + + fun localFunc() { + y = 0 + } + } + + println(x) + println(x) +} \ No newline at end of file diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/initialization/fromLocalMembers.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/initialization/fromLocalMembers.txt new file mode 100644 index 00000000000..57285c8f132 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/initialization/fromLocalMembers.txt @@ -0,0 +1,51 @@ +FILE: fromLocalMembers.kt + public final fun test1(): R|kotlin/Unit| { + lval x: R|kotlin/Int| + local final fun func(): R|kotlin/Unit| { + R|/x| = Int(0) + } + + R|kotlin/io/println|(R|/x|) + } + public final fun test2(): R|kotlin/Unit| { + lval x: R|kotlin/Int| + lval y: R|kotlin/Int| + object : R|kotlin/Any| { + private[local] constructor(): R|| { + super() + } + + init { + R|/x| = Int(0) + } + + public[local] final fun localFunc(): R|kotlin/Unit| { + R|/y| = Int(0) + } + + } + + R|kotlin/io/println|(R|/x|) + R|kotlin/io/println|(R|/x|) + } + public final fun test3(): R|kotlin/Unit| { + lval x: R|kotlin/Int| + lval y: R|kotlin/Int| + local final class A : R|kotlin/Any| { + public[local] constructor(): R|A| { + super() + } + + init { + R|/x| = Int(0) + } + + public[local] final fun localFunc(): R|kotlin/Unit| { + R|/y| = Int(0) + } + + } + + R|kotlin/io/println|(R|/x|) + R|kotlin/io/println|(R|/x|) + } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/smartcasts/tryWithLambdaInside.dot b/compiler/fir/analysis-tests/testData/resolveWithStdlib/smartcasts/tryWithLambdaInside.dot index 77032fe50c4..3af3e0d50fb 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/smartcasts/tryWithLambdaInside.dot +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/smartcasts/tryWithLambdaInside.dot @@ -106,6 +106,7 @@ finally { 16 -> {17}; 17 -> {31}; 17 -> {18} [color=red]; + 17 -> {31} [style=dashed]; 18 -> {19}; 19 -> {20}; 20 -> {21}; @@ -193,6 +194,7 @@ finally { 40 -> {41}; 41 -> {42}; 42 -> {43 56}; + 42 -> {56} [style=dashed]; 43 -> {44}; 44 -> {45}; 45 -> {46}; diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java index 993b0ccbf1a..1c9fa286ac6 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java @@ -723,6 +723,24 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic } } + @TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/initialization") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Initialization extends AbstractFirDiagnosticsWithStdlibTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInInitialization() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolveWithStdlib/initialization"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("fromLocalMembers.kt") + public void testFromLocalMembers() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/initialization/fromLocalMembers.kt"); + } + } + @TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/CfgTraverser.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/CfgTraverser.kt index 035a6b1e88a..416ed8b20be 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/CfgTraverser.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/CfgTraverser.kt @@ -18,9 +18,7 @@ fun ControlFlowGraph.traverse( ) { for (node in getNodesInOrder(direction)) { node.accept(visitor, data) - if (node is CFGNodeWithCfgOwner<*>) { - node.subGraph?.traverse(direction, visitor, data) - } + (node as? CFGNodeWithCfgOwner<*>)?.subGraphs?.forEach { it.traverse(direction, visitor, data) } } } @@ -72,7 +70,7 @@ private fun , K : Any, V : Any> ControlFlowGraph.co } } if (node is CFGNodeWithCfgOwner<*>) { - node.subGraph?.collectDataForNodeInternal(direction, initialInfo, visitor, nodeMap, changed) + node.subGraphs.forEach { it.collectDataForNodeInternal(direction, initialInfo, visitor, nodeMap, changed) } } } } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirControlFlowAnalyzer.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirControlFlowAnalyzer.kt index 6ec13167390..a8643df6d60 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirControlFlowAnalyzer.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirControlFlowAnalyzer.kt @@ -19,7 +19,7 @@ class FirControlFlowAnalyzer(session: FirSession) { fun analyzeClassInitializer(klass: FirClass<*>, graph: ControlFlowGraph, context: CheckerContext, reporter: DiagnosticReporter) { if (graph.owner != null) return - // TODO() + checkers.forEach { it.analyze(graph, reporter) } } fun analyzeFunction(function: FirFunction<*>, graph: ControlFlowGraph, context: CheckerContext, reporter: DiagnosticReporter) { @@ -29,6 +29,6 @@ class FirControlFlowAnalyzer(session: FirSession) { fun analyzePropertyInitializer(property: FirProperty, graph: ControlFlowGraph, context: CheckerContext, reporter: DiagnosticReporter) { if (graph.owner != null) return - // TODO() + checkers.forEach { it.analyze(graph, reporter) } } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt index 06fe7fdac51..be51af3c55e 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt @@ -155,7 +155,8 @@ abstract class FirDataFlowAnalyzer( enterAnonymousFunction(function) return } - val (functionEnterNode, previousNode) = graphBuilder.enterFunction(function) + val (functionEnterNode, localFunctionNode, previousNode) = graphBuilder.enterFunction(function) + localFunctionNode?.mergeIncomingFlow() functionEnterNode.mergeIncomingFlow(shouldForkFlow = previousNode != null) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNode.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNode.kt index 475921af110..aaa7c8d35fc 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNode.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNode.kt @@ -14,6 +14,7 @@ import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.resolve.dfa.controlFlowGraph import org.jetbrains.kotlin.fir.visitors.FirTransformer import org.jetbrains.kotlin.fir.visitors.FirVisitor +import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.addToStdlib.runIf sealed class CFGNode(val owner: ControlFlowGraph, val level: Int, private val id: Int) { @@ -125,8 +126,15 @@ interface ExitNodeMarker // ----------------------------------- EnterNode for declaration with CFG ----------------------------------- sealed class CFGNodeWithCfgOwner(owner: ControlFlowGraph, level: Int, id: Int) : CFGNode(owner, level, id) { - val subGraph: ControlFlowGraph? - get() = fir.controlFlowGraphReference.controlFlowGraph + private val _subGraphs = mutableListOf() + + fun addSubGraph(graph: ControlFlowGraph){ + _subGraphs += graph + } + + val subGraphs: List by lazy { + _subGraphs.also { it.addIfNotNull(fir.controlFlowGraphReference.controlFlowGraph) } + } } // ----------------------------------- Named function ----------------------------------- @@ -141,6 +149,12 @@ class FunctionExitNode(owner: ControlFlowGraph, override val fir: FirFunction<*> return visitor.visitFunctionExitNode(this, data) } } +class LocalFunctionDeclarationNode(owner: ControlFlowGraph, override val fir: FirFunction<*>, level: Int, id: Int) : CFGNodeWithCfgOwner>(owner, level, id) { + override fun accept(visitor: ControlFlowGraphVisitor, data: D): R { + return visitor.visitLocalFunctionDeclarationNode(this, data) + } +} + // ----------------------------------- Default arguments ----------------------------------- @@ -216,9 +230,17 @@ class AnonymousObjectExitNode(owner: ControlFlowGraph, override val fir: FirAnon } } +// ----------------------------------- Initialization ----------------------------------- + +class PartOfClassInitializationNode(owner: ControlFlowGraph, override val fir: FirControlFlowGraphOwner, level: Int, id: Int) : CFGNodeWithCfgOwner(owner, level, id), EnterNodeMarker { + override fun accept(visitor: ControlFlowGraphVisitor, data: D): R { + return visitor.visitPartOfClassInitializationNode(this, data) + } +} + // ----------------------------------- Property ----------------------------------- -class PropertyInitializerEnterNode(owner: ControlFlowGraph, override val fir: FirProperty, level: Int, id: Int) : CFGNodeWithCfgOwner(owner, level, id), EnterNodeMarker { +class PropertyInitializerEnterNode(owner: ControlFlowGraph, override val fir: FirProperty, level: Int, id: Int) : CFGNode(owner, level, id), EnterNodeMarker { init { owner.enterNode = this } @@ -239,7 +261,7 @@ class PropertyInitializerExitNode(owner: ControlFlowGraph, override val fir: Fir // ----------------------------------- Init ----------------------------------- -class InitBlockEnterNode(owner: ControlFlowGraph, override val fir: FirAnonymousInitializer, level: Int, id: Int) : CFGNodeWithCfgOwner(owner, level, id), EnterNodeMarker { +class InitBlockEnterNode(owner: ControlFlowGraph, override val fir: FirAnonymousInitializer, level: Int, id: Int) : CFGNode(owner, level, id), EnterNodeMarker { init { owner.enterNode = this } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNodeRenderer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNodeRenderer.kt index ad9316c7b3b..615ab88bd18 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNodeRenderer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNodeRenderer.kt @@ -19,6 +19,7 @@ fun CFGNode<*>.render(): String = when (this@render) { is FunctionEnterNode -> "Enter function \"${fir.name()}\"" is FunctionExitNode -> "Exit function \"${fir.name()}\"" + is LocalFunctionDeclarationNode -> "Local function declaration ${owner.name}" is BlockEnterNode -> "Enter block" is BlockExitNode -> "Exit block" @@ -81,6 +82,7 @@ fun CFGNode<*>.render(): String = is BinaryOrEnterRightOperandNode -> "Enter right part of ||" is BinaryOrExitNode -> "Exit ||" + is PartOfClassInitializationNode -> "Part of class initialization" is PropertyInitializerEnterNode -> "Enter property" is PropertyInitializerExitNode -> "Exit property" is InitBlockEnterNode -> "Enter init block" 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 d6efad02bda..d50bc99db1f 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 @@ -160,7 +160,7 @@ class ControlFlowGraphBuilder { // ----------------------------------- Regular function ----------------------------------- - fun enterFunction(function: FirFunction<*>): Pair?> { + fun enterFunction(function: FirFunction<*>): Triple?> { require(function !is FirAnonymousFunction) val name = when (function) { is FirSimpleFunction -> function.name.asString() @@ -170,10 +170,15 @@ class ControlFlowGraphBuilder { } val graph = ControlFlowGraph(function, name, ControlFlowGraph.Kind.Function) // function is local - if (mode == Mode.Body) { + val localFunctionNode = runIf(mode == Mode.Body) { assert(currentGraph.kind.withBody) currentGraph.addSubGraph(graph) + + createLocalFunctionDeclarationNode(function).also { + addNewSimpleNode(it) + } } + pushGraph( graph = graph, mode = Mode.Body @@ -195,7 +200,7 @@ class ControlFlowGraphBuilder { exitTargetsForTry.push(it) } - return enterNode to previousNode + return Triple(enterNode, localFunctionNode, previousNode) } fun exitFunction(function: FirFunction<*>): Pair { @@ -360,20 +365,27 @@ class ControlFlowGraphBuilder { pushGraph(classGraph, Mode.ClassInitializer) val exitNode = createClassExitNode(klass) var node: CFGNode<*> = createClassEnterNode(klass) + var prevInitPartNode: CFGNode<*>? = null for (declaration in klass.declarations) { val graph = when (declaration) { is FirProperty -> declaration.controlFlowGraphReference.controlFlowGraph is FirAnonymousInitializer -> declaration.controlFlowGraphReference.controlFlowGraph else -> null } ?: continue - addEdge(node, graph.enterNode, preferredKind = EdgeKind.CfgForward) - node = graph.exitNode - // TODO Fix this - if (graph.owner == null) { - classGraph.addSubGraph(graph) + + createPartOfClassInitializationNode(declaration as FirControlFlowGraphOwner).also { + addEdge(node, it, preferredKind = EdgeKind.CfgForward) + addEdge(it, graph.enterNode, preferredKind = EdgeKind.CfgForward) + node = graph.exitNode + + if (prevInitPartNode != null) addEdge(prevInitPartNode!!, it, preferredKind = EdgeKind.DeadForward) + it.updateDeadStatus() + prevInitPartNode = it } } addEdge(node, exitNode, preferredKind = EdgeKind.CfgForward) + if (prevInitPartNode != null) addEdge(prevInitPartNode!!, exitNode, preferredKind = EdgeKind.DeadForward) + exitNode.updateDeadStatus() return popGraph() } @@ -396,6 +408,8 @@ class ControlFlowGraphBuilder { val node = createLocalClassExitNode(klass).also { addNewSimpleNodeIfPossible(it) } + visitLocalClassFunctions(klass, node) + addEdge(node, graph.enterNode, preferredKind = EdgeKind.CfgForward) return node to graph } @@ -409,9 +423,21 @@ class ControlFlowGraphBuilder { addNewSimpleNode(it) } } + visitLocalClassFunctions(anonymousObject, node) + addEdge(node, graph.enterNode, preferredKind = EdgeKind.CfgForward) return node to graph } + fun visitLocalClassFunctions(klass: FirClass<*>, node: CFGNodeWithCfgOwner<*>) { + klass.declarations.filterIsInstance>().forEach { function -> + val functionGraph = function.controlFlowGraphReference.controlFlowGraph + if (functionGraph != null && functionGraph.owner == null) { + addEdge(node, functionGraph.enterNode, preferredKind = EdgeKind.CfgForward) + node.addSubGraph(functionGraph) + } + } + } + // ----------------------------------- Value parameters (and it's defaults) ----------------------------------- fun enterValueParameter(valueParameter: FirValueParameter): EnterDefaultArgumentsNode? { @@ -1194,3 +1220,5 @@ class ControlFlowGraphBuilder { } } + +fun FirDeclaration?.isLocalClassOrAnonymousObject() = ((this as? FirRegularClass)?.isLocal == true) || this is FirAnonymousObject \ No newline at end of file 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 5990f7f35eb..64cd282844f 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 @@ -49,6 +49,9 @@ fun ControlFlowGraphBuilder.createBlockEnterNode(fir: FirBlock): BlockEnterNode fun ControlFlowGraphBuilder.createBlockExitNode(fir: FirBlock): BlockExitNode = BlockExitNode(currentGraph, fir, levelCounter, createId()) +fun ControlFlowGraphBuilder.createPartOfClassInitializationNode(fir: FirControlFlowGraphOwner): PartOfClassInitializationNode = + PartOfClassInitializationNode(currentGraph, fir, levelCounter, createId()) + fun ControlFlowGraphBuilder.createPropertyInitializerExitNode(fir: FirProperty): PropertyInitializerExitNode = PropertyInitializerExitNode(currentGraph, fir, levelCounter, createId()) @@ -65,6 +68,9 @@ fun ControlFlowGraphBuilder.createFunctionExitNode(fir: FirFunction<*>): Functio currentGraph.exitNode = it } +fun ControlFlowGraphBuilder.createLocalFunctionDeclarationNode(fir: FirFunction<*>): LocalFunctionDeclarationNode = + LocalFunctionDeclarationNode(currentGraph, fir, levelCounter, createId()) + fun ControlFlowGraphBuilder.createBinaryOrEnterNode(fir: FirBinaryLogicExpression): BinaryOrEnterNode = BinaryOrEnterNode(currentGraph, fir, levelCounter, createId()) 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 63a09a920b1..cdcea640e93 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 @@ -122,6 +122,19 @@ class FirControlFlowGraphRenderVisitor( for (kind in EdgeKind.values()) { renderEdges(kind) } + + if (node is CFGNodeWithCfgOwner<*>) { + val subNodes = node.subGraphs + if (subNodes.isNotEmpty()) { + print( + indices.getValue(node), + EDGE, + subNodes.mapNotNull { indices[it.enterNode] }.joinToString(prefix = "{", postfix = "}", separator = " ") + ) + printWithNoIndent(" [style=dashed]") + printlnWithNoIndent(";") + } + } } for (subGraph in graph.subGraphs) { renderEdges(subGraph) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphVisitor.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphVisitor.kt index 63594c75cb8..e8d8bd1752c 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphVisitor.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphVisitor.kt @@ -18,6 +18,10 @@ abstract class ControlFlowGraphVisitor { return visitNode(node, data) } + open fun visitLocalFunctionDeclarationNode(node: LocalFunctionDeclarationNode, data: D): R { + return visitNode(node, data) + } + // ----------------------------------- Default arguments ----------------------------------- open fun visitExitDefaultArgumentsNode(node: ExitDefaultArgumentsNode, data: D): R { @@ -60,6 +64,12 @@ abstract class ControlFlowGraphVisitor { return visitNode(node, data) } + // ----------------------------------- Initialization ----------------------------------- + + open fun visitPartOfClassInitializationNode(node: PartOfClassInitializationNode, data: D): R { + return visitNode(node, data) + } + // ----------------------------------- Property ----------------------------------- open fun visitPropertyInitializerEnterNode(node: PropertyInitializerEnterNode, data: D): R { diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/checkPropertyAccessor.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/checkPropertyAccessor.fir.kt index 8ad3360dbd1..47bf574d433 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/checkPropertyAccessor.fir.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/checkPropertyAccessor.fir.kt @@ -9,7 +9,7 @@ val a: Int fun bar(): Int { val d: Int 42 - return d + return d } return b diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt2960.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt2960.fir.kt index 39fcd820981..e6e2293f0df 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt2960.fir.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt2960.fir.kt @@ -15,13 +15,13 @@ val o = object { p.x = 4 val z : Int - doSmth(z) + doSmth(z) } } val g = { -> val x: Int - doSmth(x) + doSmth(x) } class A { diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/uninitializedInLocalDeclarations.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/uninitializedInLocalDeclarations.fir.kt index e1c27fe15c1..2d028b48161 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/uninitializedInLocalDeclarations.fir.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/uninitializedInLocalDeclarations.fir.kt @@ -1,7 +1,7 @@ fun test1() { fun bar() { var i : Int - doSmth(i) + doSmth(i) } } @@ -16,7 +16,7 @@ fun test2() { doSmth(e) } - doSmth(s) + doSmth(s) } } @@ -40,7 +40,7 @@ fun test5() { fun inner3() { fun inner4() { val a : Int - doSmth(a) + doSmth(a) } } }