diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/initBlock.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/initBlock.dot index 99222657da2..f37e452fb35 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/initBlock.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/initBlock.dot @@ -15,33 +15,33 @@ digraph initBlock_kt { 2 [label="Enter class Foo" style="filled" fillcolor=red]; subgraph cluster_2 { color=blue - 3 [label="Enter init block" style="filled" fillcolor=red]; - subgraph cluster_3 { - color=blue - 4 [label="Enter block"]; - 5 [label="Const: Int(1)"]; - 6 [label="Variable declaration: lval x: R|kotlin/Int|"]; - 7 [label="Exit block"]; - } - 8 [label="Exit init block" style="filled" fillcolor=red]; + 3 [label="Enter function " style="filled" fillcolor=red]; + 4 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 5 [label="Exit function " style="filled" fillcolor=red]; } - subgraph cluster_4 { + subgraph cluster_3 { color=blue - 9 [label="Enter function " style="filled" fillcolor=red]; - 10 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; - 11 [label="Exit function " style="filled" fillcolor=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]; } 12 [label="Exit class Foo" style="filled" fillcolor=red]; } 2 -> {3} [color=green]; 2 -> {12} [style=dotted]; - 2 -> {3 9} [style=dashed]; + 2 -> {3 6} [style=dashed]; 3 -> {4}; 4 -> {5}; - 5 -> {6}; + 5 -> {6} [color=green]; 6 -> {7}; 7 -> {8}; - 8 -> {9} [color=green]; + 8 -> {9}; 9 -> {10}; 10 -> {11}; 11 -> {12} [color=green]; @@ -51,47 +51,47 @@ digraph initBlock_kt { 13 [label="Enter class Bar" style="filled" fillcolor=red]; subgraph cluster_6 { color=blue - 14 [label="Enter init block" style="filled" fillcolor=red]; - subgraph cluster_7 { - color=blue - 15 [label="Enter block"]; - 16 [label="Const: Int(1)"]; - 17 [label="Variable declaration: lval x: R|kotlin/Int|"]; - subgraph cluster_8 { - color=blue - 18 [label="Function call arguments enter"]; - 19 [label="Function call arguments exit"]; - } - 20 [label="Function call: R|java/lang/Exception.Exception|()" style="filled" fillcolor=yellow]; - 21 [label="Throw: throw R|java/lang/Exception.Exception|()"]; - 22 [label="Stub" style="filled" fillcolor=gray]; - 23 [label="Const: Int(2)" style="filled" fillcolor=gray]; - 24 [label="Variable declaration: lval y: R|kotlin/Int|" style="filled" fillcolor=gray]; - 25 [label="Exit block" style="filled" fillcolor=gray]; - } - 26 [label="Exit init block" style="filled" fillcolor=gray]; + 14 [label="Enter function " style="filled" fillcolor=red]; + 15 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 16 [label="Exit function " style="filled" fillcolor=red]; } - subgraph cluster_9 { + subgraph cluster_7 { color=blue - 27 [label="Enter function " style="filled" fillcolor=gray]; - 28 [label="Delegated constructor call: super()" style="filled" fillcolor=gray]; - 29 [label="Exit function " style="filled" fillcolor=gray]; + 17 [label="Enter init block" style="filled" fillcolor=red]; + subgraph cluster_8 { + color=blue + 18 [label="Enter block"]; + 19 [label="Const: Int(1)"]; + 20 [label="Variable declaration: lval x: R|kotlin/Int|"]; + subgraph cluster_9 { + color=blue + 21 [label="Function call arguments enter"]; + 22 [label="Function call arguments exit"]; + } + 23 [label="Function call: R|java/lang/Exception.Exception|()" style="filled" fillcolor=yellow]; + 24 [label="Throw: throw R|java/lang/Exception.Exception|()"]; + 25 [label="Stub" style="filled" fillcolor=gray]; + 26 [label="Const: Int(2)" style="filled" fillcolor=gray]; + 27 [label="Variable declaration: lval y: R|kotlin/Int|" style="filled" fillcolor=gray]; + 28 [label="Exit block" style="filled" fillcolor=gray]; + } + 29 [label="Exit init block" style="filled" fillcolor=gray]; } 30 [label="Exit class Bar" style="filled" fillcolor=gray]; } 13 -> {14} [color=green]; 13 -> {30} [style=dotted]; - 13 -> {14 27} [style=dashed]; + 13 -> {14 17} [style=dashed]; 14 -> {15}; 15 -> {16}; - 16 -> {17}; + 16 -> {17} [color=green]; 17 -> {18}; 18 -> {19}; 19 -> {20}; 20 -> {21}; - 21 -> {22} [style=dotted]; - 22 -> {23} [style=dotted]; - 23 -> {24} [style=dotted]; + 21 -> {22}; + 22 -> {23}; + 23 -> {24}; 24 -> {25} [style=dotted]; 25 -> {26} [style=dotted]; 26 -> {27} [style=dotted]; diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/initBlockAndInPlaceLambda.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/initBlockAndInPlaceLambda.dot index 2482b221e76..2f94ed32439 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/initBlockAndInPlaceLambda.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/initBlockAndInPlaceLambda.dot @@ -29,81 +29,81 @@ digraph initBlockAndInPlaceLambda_kt { 6 [label="Enter class C" style="filled" fillcolor=red]; subgraph cluster_4 { color=blue - 7 [label="Enter init block" style="filled" fillcolor=red]; - subgraph cluster_5 { - color=blue - 8 [label="Enter block"]; - 9 [label="Access variable R|/a|"]; - 10 [label="Access variable R|/A.b|"]; - 11 [label="Enter safe call"]; - subgraph cluster_6 { - color=blue - 12 [label="Function call arguments enter"]; - 13 [label="Postponed enter to lambda"]; - subgraph cluster_7 { - color=blue - 14 [label="Enter function " style="filled" fillcolor=red]; - subgraph cluster_8 { - color=blue - 15 [label="Enter block"]; - subgraph cluster_9 { - color=blue - 16 [label="Function call arguments enter"]; - 17 [label="Access variable R|/a|"]; - 18 [label="Access variable R|/it|"]; - 19 [label="Function call arguments exit"]; - } - 20 [label="Function call: R|/C.C|(...)" style="filled" fillcolor=yellow]; - 21 [label="Exit block"]; - } - 22 [label="Exit function " style="filled" fillcolor=red]; - } - 23 [label="Function call arguments exit"]; - } - 24 [label="Postponed exit from lambda"]; - 25 [label="Function call: $subj$.R|kotlin/let|(...)" style="filled" fillcolor=yellow]; - 26 [label="Exit safe call"]; - 27 [label="Variable declaration: lval c: R|C?|"]; - 28 [label="Exit block"]; - } - 29 [label="Exit init block" style="filled" fillcolor=red]; + 7 [label="Enter function " style="filled" fillcolor=red]; + 8 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 9 [label="Exit function " style="filled" fillcolor=red]; } - subgraph cluster_10 { + subgraph cluster_5 { color=blue - 30 [label="Enter function " style="filled" fillcolor=red]; - 31 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; - 32 [label="Exit function " style="filled" fillcolor=red]; + 10 [label="Enter init block" style="filled" fillcolor=red]; + subgraph cluster_6 { + color=blue + 11 [label="Enter block"]; + 12 [label="Access variable R|/a|"]; + 13 [label="Access variable R|/A.b|"]; + 14 [label="Enter safe call"]; + subgraph cluster_7 { + color=blue + 15 [label="Function call arguments enter"]; + 16 [label="Postponed enter to lambda"]; + subgraph cluster_8 { + color=blue + 17 [label="Enter function " style="filled" fillcolor=red]; + subgraph cluster_9 { + color=blue + 18 [label="Enter block"]; + subgraph cluster_10 { + color=blue + 19 [label="Function call arguments enter"]; + 20 [label="Access variable R|/a|"]; + 21 [label="Access variable R|/it|"]; + 22 [label="Function call arguments exit"]; + } + 23 [label="Function call: R|/C.C|(...)" style="filled" fillcolor=yellow]; + 24 [label="Exit block"]; + } + 25 [label="Exit function " style="filled" fillcolor=red]; + } + 26 [label="Function call arguments exit"]; + } + 27 [label="Postponed exit from lambda"]; + 28 [label="Function call: $subj$.R|kotlin/let|(...)" style="filled" fillcolor=yellow]; + 29 [label="Exit safe call"]; + 30 [label="Variable declaration: lval c: R|C?|"]; + 31 [label="Exit block"]; + } + 32 [label="Exit init block" style="filled" fillcolor=red]; } 33 [label="Exit class C" style="filled" fillcolor=red]; } 6 -> {7} [color=green]; 6 -> {33} [style=dotted]; - 6 -> {7 30} [style=dashed]; + 6 -> {7 10} [style=dashed]; 7 -> {8}; 8 -> {9}; - 9 -> {10}; - 10 -> {11 26}; + 9 -> {10} [color=green]; + 10 -> {11}; 11 -> {12}; 12 -> {13}; - 13 -> {14 23}; - 13 -> {24} [style=dotted]; - 13 -> {14} [style=dashed]; + 13 -> {14 29}; 14 -> {15}; 15 -> {16}; - 16 -> {17}; + 16 -> {17 26}; + 16 -> {27} [style=dotted]; + 16 -> {17} [style=dashed]; 17 -> {18}; 18 -> {19}; 19 -> {20}; 20 -> {21}; 21 -> {22}; - 22 -> {24}; - 23 -> {25}; - 24 -> {25} [label="Postponed"]; - 25 -> {26}; - 26 -> {27}; - 27 -> {28}; + 22 -> {23}; + 23 -> {24}; + 24 -> {25}; + 25 -> {27}; + 26 -> {28}; + 27 -> {28} [label="Postponed"]; 28 -> {29}; - 29 -> {30} [color=green]; + 29 -> {30}; 30 -> {31}; 31 -> {32}; 32 -> {33} [color=green]; diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/nestedClass.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/nestedClass.dot index 3411d480b2b..357e2d4facf 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/nestedClass.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/nestedClass.dot @@ -15,21 +15,21 @@ digraph nestedClass_kt { 2 [label="Enter class OuterClass" style="filled" fillcolor=red]; subgraph cluster_2 { color=blue - 3 [label="Enter property" style="filled" fillcolor=red]; - 4 [label="Const: Int(1)"]; - 5 [label="Exit property" style="filled" fillcolor=red]; + 3 [label="Enter function " style="filled" fillcolor=red]; + 4 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 5 [label="Exit function " style="filled" fillcolor=red]; } subgraph cluster_3 { color=blue 6 [label="Enter property" style="filled" fillcolor=red]; - 7 [label="Access variable R|/OuterClass.outerProperty|"]; + 7 [label="Const: Int(1)"]; 8 [label="Exit property" style="filled" fillcolor=red]; } subgraph cluster_4 { color=blue - 9 [label="Enter function " style="filled" fillcolor=red]; - 10 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; - 11 [label="Exit function " style="filled" fillcolor=red]; + 9 [label="Enter property" style="filled" fillcolor=red]; + 10 [label="Access variable R|/OuterClass.outerProperty|"]; + 11 [label="Exit property" style="filled" fillcolor=red]; } 12 [label="Exit class OuterClass" style="filled" fillcolor=red]; } @@ -65,21 +65,21 @@ digraph nestedClass_kt { 17 [label="Enter class NestedClass" style="filled" fillcolor=red]; subgraph cluster_8 { color=blue - 18 [label="Enter property" style="filled" fillcolor=red]; - 19 [label="Const: Int(1)"]; - 20 [label="Exit property" style="filled" fillcolor=red]; + 18 [label="Enter function " style="filled" fillcolor=red]; + 19 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 20 [label="Exit function " style="filled" fillcolor=red]; } subgraph cluster_9 { color=blue 21 [label="Enter property" style="filled" fillcolor=red]; - 22 [label="Access variable R|/OuterClass.NestedClass.nestedProperty|"]; + 22 [label="Const: Int(1)"]; 23 [label="Exit property" style="filled" fillcolor=red]; } subgraph cluster_10 { color=blue - 24 [label="Enter function " style="filled" fillcolor=red]; - 25 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; - 26 [label="Exit function " style="filled" fillcolor=red]; + 24 [label="Enter property" style="filled" fillcolor=red]; + 25 [label="Access variable R|/OuterClass.NestedClass.nestedProperty|"]; + 26 [label="Exit property" style="filled" fillcolor=red]; } 27 [label="Exit class NestedClass" style="filled" fillcolor=red]; } diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/postponedLambdaInConstructor.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/postponedLambdaInConstructor.dot index e6459390979..6d674a6eaed 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/postponedLambdaInConstructor.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/postponedLambdaInConstructor.dot @@ -33,74 +33,74 @@ digraph postponedLambdaInConstructor_kt { 7 [label="Enter class B" style="filled" fillcolor=red]; subgraph cluster_4 { color=blue - 8 [label="Enter property" style="filled" fillcolor=red]; - 9 [label="Access variable R|/s|"]; - 10 [label="Exit property" style="filled" fillcolor=red]; - } - subgraph cluster_5 { - color=blue - 11 [label="Enter function " style="filled" fillcolor=red]; - subgraph cluster_6 { + 8 [label="Enter function " style="filled" fillcolor=red]; + subgraph cluster_5 { color=blue - 12 [label="Function call arguments enter"]; - 13 [label="Access variable R|/s|"]; - 14 [label="Postponed enter to lambda"]; - subgraph cluster_7 { + 9 [label="Function call arguments enter"]; + 10 [label="Access variable R|/s|"]; + 11 [label="Postponed enter to lambda"]; + subgraph cluster_6 { color=blue - 15 [label="Enter function " style="filled" fillcolor=red]; - subgraph cluster_8 { + 12 [label="Enter function " style="filled" fillcolor=red]; + subgraph cluster_7 { color=blue - 16 [label="Enter block"]; - 17 [label="Exit anonymous function expression"]; - subgraph cluster_9 { + 13 [label="Enter block"]; + 14 [label="Exit anonymous function expression"]; + subgraph cluster_8 { color=blue - 18 [label="Enter function " style="filled" fillcolor=red]; - subgraph cluster_10 { + 15 [label="Enter function " style="filled" fillcolor=red]; + subgraph cluster_9 { color=blue - 19 [label="Enter block"]; - 20 [label="Access variable R|/it|"]; - 21 [label="Exit block"]; + 16 [label="Enter block"]; + 17 [label="Access variable R|/it|"]; + 18 [label="Exit block"]; } - 22 [label="Exit function " style="filled" fillcolor=red]; + 19 [label="Exit function " style="filled" fillcolor=red]; } - 23 [label="Exit block"]; + 20 [label="Exit block"]; } - 24 [label="Exit function " style="filled" fillcolor=red]; + 21 [label="Exit function " style="filled" fillcolor=red]; } - 25 [label="Function call arguments exit"]; + 22 [label="Function call arguments exit"]; } - 26 [label="Postponed exit from lambda"]; - 27 [label="Function call: R|/s|.R|kotlin/let| kotlin/String|>(...)" style="filled" fillcolor=yellow]; - 28 [label="Delegated constructor call: super(...)" style="filled" fillcolor=yellow]; - 29 [label="Exit function " style="filled" fillcolor=red]; + 23 [label="Postponed exit from lambda"]; + 24 [label="Function call: R|/s|.R|kotlin/let| kotlin/String|>(...)" style="filled" fillcolor=yellow]; + 25 [label="Delegated constructor call: super(...)" style="filled" fillcolor=yellow]; + 26 [label="Exit function " style="filled" fillcolor=red]; + } + subgraph cluster_10 { + color=blue + 27 [label="Enter property" style="filled" fillcolor=red]; + 28 [label="Access variable R|/s|"]; + 29 [label="Exit property" style="filled" fillcolor=red]; } 30 [label="Exit class B" style="filled" fillcolor=red]; } 7 -> {8} [color=green]; 7 -> {30} [style=dotted]; - 7 -> {8 11} [style=dashed]; + 7 -> {8 27} [style=dashed]; 8 -> {9}; 9 -> {10}; - 10 -> {11} [color=green]; - 11 -> {12}; + 10 -> {11}; + 11 -> {12 22}; + 11 -> {23} [style=dotted]; + 11 -> {12} [style=dashed]; 12 -> {13}; 13 -> {14}; - 14 -> {15 25}; - 14 -> {26} [style=dotted]; + 14 -> {15 20}; 14 -> {15} [style=dashed]; 15 -> {16}; 16 -> {17}; - 17 -> {18 23}; - 17 -> {18} [style=dashed]; + 17 -> {18}; 18 -> {19}; - 19 -> {20}; 20 -> {21}; - 21 -> {22}; - 23 -> {24}; - 24 -> {26}; - 25 -> {27}; + 21 -> {23}; + 22 -> {24}; + 23 -> {24} [color=green]; + 23 -> {25} [color=red label="Postponed"]; + 24 -> {25}; + 25 -> {26}; 26 -> {27} [color=green]; - 26 -> {28} [color=red label="Postponed"]; 27 -> {28}; 28 -> {29}; 29 -> {30} [color=green]; diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/propertiesAndInitBlocks.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/propertiesAndInitBlocks.dot index 37f0e17e4eb..2e7630f8aa6 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/propertiesAndInitBlocks.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/propertiesAndInitBlocks.dot @@ -50,28 +50,28 @@ digraph propertiesAndInitBlocks_kt { 21 [label="Enter class InitializerLocalClass" style="filled" fillcolor=red]; subgraph cluster_9 { color=blue - 22 [label="Enter init block" style="filled" fillcolor=red]; - subgraph cluster_10 { - color=blue - 23 [label="Enter block"]; - subgraph cluster_11 { - color=blue - 24 [label="Function call arguments enter"]; - 25 [label="Function call arguments exit"]; - } - 26 [label="Function call: R|java/lang/Exception.Exception|()" style="filled" fillcolor=yellow]; - 27 [label="Throw: throw R|java/lang/Exception.Exception|()"]; - 28 [label="Stub" style="filled" fillcolor=gray]; - 29 [label="Const: Int(1)" style="filled" fillcolor=gray]; - 30 [label="Exit block" style="filled" fillcolor=gray]; - } - 31 [label="Exit init block" style="filled" fillcolor=gray]; + 22 [label="Enter function " style="filled" fillcolor=red]; + 23 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 24 [label="Exit function " style="filled" fillcolor=red]; } - subgraph cluster_12 { + subgraph cluster_10 { color=blue - 32 [label="Enter function " style="filled" fillcolor=gray]; - 33 [label="Delegated constructor call: super()" style="filled" fillcolor=gray]; - 34 [label="Exit function " style="filled" fillcolor=gray]; + 25 [label="Enter init block" style="filled" fillcolor=red]; + subgraph cluster_11 { + color=blue + 26 [label="Enter block"]; + subgraph cluster_12 { + color=blue + 27 [label="Function call arguments enter"]; + 28 [label="Function call arguments exit"]; + } + 29 [label="Function call: R|java/lang/Exception.Exception|()" style="filled" fillcolor=yellow]; + 30 [label="Throw: throw R|java/lang/Exception.Exception|()"]; + 31 [label="Stub" style="filled" fillcolor=gray]; + 32 [label="Const: Int(1)" style="filled" fillcolor=gray]; + 33 [label="Exit block" style="filled" fillcolor=gray]; + } + 34 [label="Exit init block" style="filled" fillcolor=gray]; } 35 [label="Exit class InitializerLocalClass" style="filled" fillcolor=gray]; } @@ -181,17 +181,17 @@ digraph propertiesAndInitBlocks_kt { 19 -> {20} [style=dotted]; 20 -> {52} [style=dotted]; 21 -> {22}; - 21 -> {32} [color=red]; + 21 -> {25} [color=red]; 21 -> {35} [style=dotted]; - 21 -> {22 32} [style=dashed]; + 21 -> {22 25} [style=dashed]; 22 -> {23}; 23 -> {24}; - 24 -> {25}; + 24 -> {25} [color=green]; 25 -> {26}; 26 -> {27}; - 27 -> {28} [style=dotted]; - 28 -> {29} [style=dotted]; - 29 -> {30} [style=dotted]; + 27 -> {28}; + 28 -> {29}; + 29 -> {30}; 30 -> {31} [style=dotted]; 31 -> {32} [style=dotted]; 32 -> {33} [style=dotted]; @@ -317,27 +317,27 @@ digraph propertiesAndInitBlocks_kt { 101 [label="Enter class GetterLocalClass" style="filled" fillcolor=red]; subgraph cluster_35 { color=blue - 102 [label="Enter init block" style="filled" fillcolor=red]; - subgraph cluster_36 { - color=blue - 103 [label="Enter block"]; - subgraph cluster_37 { - color=blue - 104 [label="Function call arguments enter"]; - 105 [label="Function call arguments exit"]; - } - 106 [label="Function call: R|java/lang/Exception.Exception|()" style="filled" fillcolor=yellow]; - 107 [label="Throw: throw R|java/lang/Exception.Exception|()"]; - 108 [label="Stub" style="filled" fillcolor=gray]; - 109 [label="Exit block" style="filled" fillcolor=gray]; - } - 110 [label="Exit init block" style="filled" fillcolor=gray]; + 102 [label="Enter function " style="filled" fillcolor=red]; + 103 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 104 [label="Exit function " style="filled" fillcolor=red]; } - subgraph cluster_38 { + subgraph cluster_36 { color=blue - 111 [label="Enter function " style="filled" fillcolor=gray]; - 112 [label="Delegated constructor call: super()" style="filled" fillcolor=gray]; - 113 [label="Exit function " style="filled" fillcolor=gray]; + 105 [label="Enter init block" style="filled" fillcolor=red]; + subgraph cluster_37 { + color=blue + 106 [label="Enter block"]; + subgraph cluster_38 { + color=blue + 107 [label="Function call arguments enter"]; + 108 [label="Function call arguments exit"]; + } + 109 [label="Function call: R|java/lang/Exception.Exception|()" style="filled" fillcolor=yellow]; + 110 [label="Throw: throw R|java/lang/Exception.Exception|()"]; + 111 [label="Stub" style="filled" fillcolor=gray]; + 112 [label="Exit block" style="filled" fillcolor=gray]; + } + 113 [label="Exit init block" style="filled" fillcolor=gray]; } 114 [label="Exit class GetterLocalClass" style="filled" fillcolor=gray]; } @@ -347,17 +347,17 @@ digraph propertiesAndInitBlocks_kt { 98 -> {101} [style=dashed]; 99 -> {100}; 101 -> {102}; - 101 -> {111} [color=red]; + 101 -> {105} [color=red]; 101 -> {114} [style=dotted]; - 101 -> {102 111} [style=dashed]; + 101 -> {102 105} [style=dashed]; 102 -> {103}; 103 -> {104}; - 104 -> {105}; + 104 -> {105} [color=green]; 105 -> {106}; 106 -> {107}; - 107 -> {108} [style=dotted]; - 108 -> {109} [style=dotted]; - 109 -> {110} [style=dotted]; + 107 -> {108}; + 108 -> {109}; + 109 -> {110}; 110 -> {111} [style=dotted]; 111 -> {112} [style=dotted]; 112 -> {113} [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 c5f94143ca7..27b57311b50 100644 --- a/compiler/fir/analysis-tests/testData/resolve/problems/secondaryConstructorCfg.dot +++ b/compiler/fir/analysis-tests/testData/resolve/problems/secondaryConstructorCfg.dot @@ -20,37 +20,37 @@ digraph secondaryConstructorCfg_kt { 5 [label="Delegated constructor call: this(...)" style="filled" fillcolor=yellow]; subgraph cluster_3 { color=blue - 6 [label="Enter property" style="filled" fillcolor=red]; - 7 [label="Access variable R|/p0|"]; - 8 [label="Exit property" style="filled" fillcolor=red]; + 6 [label="Enter function " style="filled" fillcolor=red]; + 7 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 8 [label="Exit function " style="filled" fillcolor=red]; } subgraph cluster_4 { color=blue 9 [label="Enter property" style="filled" fillcolor=red]; 10 [label="Access variable R|/p0|"]; - 11 [label="Access variable R|kotlin/String.length|"]; - 12 [label="Exit property" style="filled" fillcolor=red]; + 11 [label="Exit property" style="filled" fillcolor=red]; } subgraph cluster_5 { color=blue - 13 [label="Enter init block" style="filled" fillcolor=red]; - subgraph cluster_6 { - color=blue - 14 [label="Enter block"]; - 15 [label="Access variable R|/p0|"]; - 16 [label="Access variable R|kotlin/String.length|"]; - 17 [label="Assignment: R|/B.p1|"]; - 18 [label="Const: String()"]; - 19 [label="Assignment: R|/B.p3|"]; - 20 [label="Exit block"]; - } - 21 [label="Exit init block" style="filled" fillcolor=red]; + 12 [label="Enter property" style="filled" fillcolor=red]; + 13 [label="Access variable R|/p0|"]; + 14 [label="Access variable R|kotlin/String.length|"]; + 15 [label="Exit property" style="filled" fillcolor=red]; } - subgraph cluster_7 { + subgraph cluster_6 { color=blue - 22 [label="Enter function " style="filled" fillcolor=red]; - 23 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; - 24 [label="Exit function " style="filled" fillcolor=red]; + 16 [label="Enter init block" style="filled" fillcolor=red]; + subgraph cluster_7 { + color=blue + 17 [label="Enter block"]; + 18 [label="Access variable R|/p0|"]; + 19 [label="Access variable R|kotlin/String.length|"]; + 20 [label="Assignment: R|/B.p1|"]; + 21 [label="Const: String()"]; + 22 [label="Assignment: R|/B.p3|"]; + 23 [label="Exit block"]; + } + 24 [label="Exit init block" style="filled" fillcolor=red]; } subgraph cluster_8 { color=blue @@ -65,7 +65,7 @@ digraph secondaryConstructorCfg_kt { } 2 -> {3 6} [color=green]; 2 -> {30} [style=dotted]; - 2 -> {3 6 9 13 22} [style=dashed]; + 2 -> {3 6 9 12 16} [style=dashed]; 3 -> {4}; 4 -> {5}; 5 -> {6} [color=green label="return@/B.B"]; @@ -75,17 +75,17 @@ digraph secondaryConstructorCfg_kt { 8 -> {9} [color=green]; 9 -> {10}; 10 -> {11}; - 11 -> {12}; - 12 -> {13} [color=green]; + 11 -> {12} [color=green]; + 12 -> {13}; 13 -> {14}; 14 -> {15}; - 15 -> {16}; + 15 -> {16} [color=green]; 16 -> {17}; 17 -> {18}; 18 -> {19}; 19 -> {20}; 20 -> {21}; - 21 -> {22} [color=green]; + 21 -> {22}; 22 -> {23}; 23 -> {24}; 24 -> {25} [color=green label="return@/B.B"]; 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 0a24f9c9681..c4ba4437018 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.dot @@ -423,15 +423,15 @@ digraph boundSmartcasts_kt { 149 [label="Enter class D" style="filled" fillcolor=red]; subgraph cluster_40 { color=blue - 150 [label="Enter property" style="filled" fillcolor=red]; - 151 [label="Access variable R|/any|"]; - 152 [label="Exit property" style="filled" fillcolor=red]; + 150 [label="Enter function " style="filled" fillcolor=red]; + 151 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 152 [label="Exit function " style="filled" fillcolor=red]; } subgraph cluster_41 { color=blue - 153 [label="Enter function " style="filled" fillcolor=red]; - 154 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; - 155 [label="Exit function " style="filled" fillcolor=red]; + 153 [label="Enter property" style="filled" fillcolor=red]; + 154 [label="Access variable R|/any|"]; + 155 [label="Exit property" style="filled" fillcolor=red]; } 156 [label="Exit class D" style="filled" fillcolor=red]; } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastsInBranches.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastsInBranches.dot index de1a441a08d..fb34876cf3e 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastsInBranches.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastsInBranches.dot @@ -15,15 +15,15 @@ digraph boundSmartcastsInBranches_kt { 2 [label="Enter class A" style="filled" fillcolor=red]; subgraph cluster_2 { color=blue - 3 [label="Enter property" style="filled" fillcolor=red]; - 4 [label="Const: String()"]; - 5 [label="Exit property" style="filled" fillcolor=red]; + 3 [label="Enter function " style="filled" fillcolor=red]; + 4 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 5 [label="Exit function " style="filled" fillcolor=red]; } subgraph cluster_3 { color=blue - 6 [label="Enter function " style="filled" fillcolor=red]; - 7 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; - 8 [label="Exit function " style="filled" fillcolor=red]; + 6 [label="Enter property" style="filled" fillcolor=red]; + 7 [label="Const: String()"]; + 8 [label="Exit property" style="filled" fillcolor=red]; } 9 [label="Exit class A" style="filled" fillcolor=red]; } 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 2286a6e3a4e..640a9100a46 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/functionCallBound.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/functionCallBound.dot @@ -33,15 +33,15 @@ digraph functionCallBound_kt { 7 [label="Enter class Sub" style="filled" fillcolor=red]; subgraph cluster_4 { color=blue - 8 [label="Enter property" style="filled" fillcolor=red]; - 9 [label="Access variable R|/data|"]; - 10 [label="Exit property" style="filled" fillcolor=red]; + 8 [label="Enter function " style="filled" fillcolor=red]; + 9 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 10 [label="Exit function " style="filled" fillcolor=red]; } subgraph cluster_5 { color=blue - 11 [label="Enter function " style="filled" fillcolor=red]; - 12 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; - 13 [label="Exit function " style="filled" fillcolor=red]; + 11 [label="Enter property" style="filled" fillcolor=red]; + 12 [label="Access variable R|/data|"]; + 13 [label="Exit property" style="filled" fillcolor=red]; } 14 [label="Exit class Sub" style="filled" fillcolor=red]; } 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 49b43ec5573..ccf471e881a 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/lambdas/lambdaInWhenBranch.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/lambdas/lambdaInWhenBranch.dot @@ -33,15 +33,15 @@ digraph lambdaInWhenBranch_kt { 7 [label="Enter class SubClass1" style="filled" fillcolor=red]; subgraph cluster_4 { color=blue - 8 [label="Enter property" style="filled" fillcolor=red]; - 9 [label="Access variable R|/t|"]; - 10 [label="Exit property" style="filled" fillcolor=red]; + 8 [label="Enter function " style="filled" fillcolor=red]; + 9 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 10 [label="Exit function " style="filled" fillcolor=red]; } subgraph cluster_5 { color=blue - 11 [label="Enter function " style="filled" fillcolor=red]; - 12 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; - 13 [label="Exit function " style="filled" fillcolor=red]; + 11 [label="Enter property" style="filled" fillcolor=red]; + 12 [label="Access variable R|/t|"]; + 13 [label="Exit property" style="filled" fillcolor=red]; } 14 [label="Exit class SubClass1" style="filled" fillcolor=red]; } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/nullability.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/nullability.dot index f2fcccc3791..cfc5b202ab5 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/nullability.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/nullability.dot @@ -64,15 +64,15 @@ digraph nullability_kt { 16 [label="Enter class QImpl" style="filled" fillcolor=red]; subgraph cluster_9 { color=blue - 17 [label="Enter property" style="filled" fillcolor=red]; - 18 [label="Access variable R|/data|"]; - 19 [label="Exit property" style="filled" fillcolor=red]; + 17 [label="Enter function " style="filled" fillcolor=red]; + 18 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 19 [label="Exit function " style="filled" fillcolor=red]; } subgraph cluster_10 { color=blue - 20 [label="Enter function " style="filled" fillcolor=red]; - 21 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; - 22 [label="Exit function " style="filled" fillcolor=red]; + 20 [label="Enter property" style="filled" fillcolor=red]; + 21 [label="Access variable R|/data|"]; + 22 [label="Exit property" style="filled" fillcolor=red]; } 23 [label="Exit class QImpl" style="filled" fillcolor=red]; } @@ -112,15 +112,15 @@ digraph nullability_kt { 31 [label="Enter class QImplMutable" style="filled" fillcolor=red]; subgraph cluster_14 { color=blue - 32 [label="Enter property" style="filled" fillcolor=red]; - 33 [label="Access variable R|/data|"]; - 34 [label="Exit property" style="filled" fillcolor=red]; + 32 [label="Enter function " style="filled" fillcolor=red]; + 33 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 34 [label="Exit function " style="filled" fillcolor=red]; } subgraph cluster_15 { color=blue - 35 [label="Enter function " style="filled" fillcolor=red]; - 36 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; - 37 [label="Exit function " style="filled" fillcolor=red]; + 35 [label="Enter property" style="filled" fillcolor=red]; + 36 [label="Access variable R|/data|"]; + 37 [label="Exit property" style="filled" fillcolor=red]; } 38 [label="Exit class QImplMutable" style="filled" fillcolor=red]; } 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 0cda31bdc27..61642d9dec4 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/assignSafeCall.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/assignSafeCall.dot @@ -15,15 +15,15 @@ digraph assignSafeCall_kt { 2 [label="Enter class A" style="filled" fillcolor=red]; subgraph cluster_2 { color=blue - 3 [label="Enter property" style="filled" fillcolor=red]; - 4 [label="Const: Int(1)"]; - 5 [label="Exit property" style="filled" fillcolor=red]; + 3 [label="Enter function " style="filled" fillcolor=red]; + 4 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 5 [label="Exit function " style="filled" fillcolor=red]; } subgraph cluster_3 { color=blue - 6 [label="Enter function " style="filled" fillcolor=red]; - 7 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; - 8 [label="Exit function " style="filled" fillcolor=red]; + 6 [label="Enter property" style="filled" fillcolor=red]; + 7 [label="Const: Int(1)"]; + 8 [label="Exit property" style="filled" fillcolor=red]; } 9 [label="Exit class A" style="filled" fillcolor=red]; } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartCastInInit.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartCastInInit.dot index 6b635b264d5..7397b1a62a8 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartCastInInit.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartCastInInit.dot @@ -65,43 +65,43 @@ digraph smartCastInInit_kt { 18 [label="Enter class Main" style="filled" fillcolor=red]; subgraph cluster_8 { color=blue - 19 [label="Enter init block" style="filled" fillcolor=red]; - subgraph cluster_9 { + 19 [label="Enter function " style="filled" fillcolor=red]; + 20 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 21 [label="Exit function " style="filled" fillcolor=red]; + } + subgraph cluster_9 { + color=blue + 22 [label="Enter init block" style="filled" fillcolor=red]; + subgraph cluster_10 { color=blue - 20 [label="Enter block"]; - subgraph cluster_10 { - color=blue - 21 [label="Function call arguments enter"]; - 22 [label="Function call arguments exit"]; - } - 23 [label="Function call: R|/s|()" style="filled" fillcolor=yellow]; - 24 [label="Assignment: R|/Main.x|"]; + 23 [label="Enter block"]; subgraph cluster_11 { color=blue - 25 [label="Function call arguments enter"]; - 26 [label="Access variable R|/Main.x|"]; - 27 [label="Smart cast: this@R|/Main|.R|/Main.x|"]; - 28 [label="Function call arguments exit"]; + 24 [label="Function call arguments enter"]; + 25 [label="Function call arguments exit"]; } - 29 [label="Function call: this@R|/Main|.R|/Main.x|.R|/S.foo|()" style="filled" fillcolor=yellow]; - 30 [label="Exit block"]; + 26 [label="Function call: R|/s|()" style="filled" fillcolor=yellow]; + 27 [label="Assignment: R|/Main.x|"]; + subgraph cluster_12 { + color=blue + 28 [label="Function call arguments enter"]; + 29 [label="Access variable R|/Main.x|"]; + 30 [label="Smart cast: this@R|/Main|.R|/Main.x|"]; + 31 [label="Function call arguments exit"]; + } + 32 [label="Function call: this@R|/Main|.R|/Main.x|.R|/S.foo|()" style="filled" fillcolor=yellow]; + 33 [label="Exit block"]; } - 31 [label="Exit init block" style="filled" fillcolor=red]; - } - subgraph cluster_12 { - color=blue - 32 [label="Enter function " style="filled" fillcolor=red]; - 33 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; - 34 [label="Exit function " style="filled" fillcolor=red]; + 34 [label="Exit init block" style="filled" fillcolor=red]; } 35 [label="Exit class Main" style="filled" fillcolor=red]; } 18 -> {19} [color=green]; 18 -> {35} [style=dotted]; - 18 -> {19 32} [style=dashed]; + 18 -> {19 22} [style=dashed]; 19 -> {20}; 20 -> {21}; - 21 -> {22}; + 21 -> {22} [color=green]; 22 -> {23}; 23 -> {24}; 24 -> {25}; @@ -111,7 +111,7 @@ digraph smartCastInInit_kt { 28 -> {29}; 29 -> {30}; 30 -> {31}; - 31 -> {32} [color=green]; + 31 -> {32}; 32 -> {33}; 33 -> {34}; 34 -> {35} [color=green]; diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastInByClause.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastInByClause.dot index fe85c7418a0..c10aa12eed1 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastInByClause.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastInByClause.dot @@ -15,21 +15,21 @@ digraph smartcastInByClause_kt { 2 [label="Enter class A" style="filled" fillcolor=red]; subgraph cluster_2 { color=blue - 3 [label="Enter property" style="filled" fillcolor=red]; - 4 [label="Access variable R|/path|"]; - 5 [label="Exit property" style="filled" fillcolor=red]; + 3 [label="Enter function " style="filled" fillcolor=red]; + 4 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 5 [label="Exit function " style="filled" fillcolor=red]; } subgraph cluster_3 { color=blue 6 [label="Enter property" style="filled" fillcolor=red]; - 7 [label="Access variable R|/index|"]; + 7 [label="Access variable R|/path|"]; 8 [label="Exit property" style="filled" fillcolor=red]; } subgraph cluster_4 { color=blue - 9 [label="Enter function " style="filled" fillcolor=red]; - 10 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; - 11 [label="Exit function " style="filled" fillcolor=red]; + 9 [label="Enter property" style="filled" fillcolor=red]; + 10 [label="Access variable R|/index|"]; + 11 [label="Exit property" style="filled" fillcolor=red]; } 12 [label="Exit class A" style="filled" fillcolor=red]; } @@ -58,15 +58,15 @@ digraph smartcastInByClause_kt { 15 [label="Enter class Derived" style="filled" fillcolor=red]; subgraph cluster_7 { color=blue - 16 [label="Enter property" style="filled" fillcolor=red]; - 17 [label="Access variable R|/index|"]; - 18 [label="Exit property" style="filled" fillcolor=red]; + 16 [label="Enter function " style="filled" fillcolor=red]; + 17 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 18 [label="Exit function " style="filled" fillcolor=red]; } subgraph cluster_8 { color=blue - 19 [label="Enter function " style="filled" fillcolor=red]; - 20 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; - 21 [label="Exit function " style="filled" fillcolor=red]; + 19 [label="Enter property" style="filled" fillcolor=red]; + 20 [label="Access variable R|/index|"]; + 21 [label="Exit property" style="filled" fillcolor=red]; } 22 [label="Exit class Derived" style="filled" fillcolor=red]; } @@ -113,31 +113,31 @@ digraph smartcastInByClause_kt { 44 [label="Enter class " style="filled" fillcolor=red]; subgraph cluster_13 { color=blue - 45 [label="Enter field" style="filled" fillcolor=red]; - subgraph cluster_14 { - color=blue - 46 [label="Function call arguments enter"]; - 47 [label="Access variable R|/a|"]; - 48 [label="Smart cast: R|/a|"]; - 49 [label="Access variable R|/A.index|"]; - 50 [label="Function call arguments exit"]; - } - 51 [label="Function call: R|/Derived.Derived|(...)" style="filled" fillcolor=yellow]; - 52 [label="Exit field" style="filled" fillcolor=red]; + 45 [label="Enter function " style="filled" fillcolor=red]; + 46 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 47 [label="Exit function " style="filled" fillcolor=red]; } - subgraph cluster_15 { + subgraph cluster_14 { color=blue - 53 [label="Enter property" style="filled" fillcolor=red]; - 54 [label="Access variable R|/a|"]; - 55 [label="Smart cast: R|/a|"]; - 56 [label="Access variable R|/A.index|"]; - 57 [label="Exit property" style="filled" fillcolor=red]; + 48 [label="Enter field" style="filled" fillcolor=red]; + subgraph cluster_15 { + color=blue + 49 [label="Function call arguments enter"]; + 50 [label="Access variable R|/a|"]; + 51 [label="Smart cast: R|/a|"]; + 52 [label="Access variable R|/A.index|"]; + 53 [label="Function call arguments exit"]; + } + 54 [label="Function call: R|/Derived.Derived|(...)" style="filled" fillcolor=yellow]; + 55 [label="Exit field" style="filled" fillcolor=red]; } subgraph cluster_16 { color=blue - 58 [label="Enter function " style="filled" fillcolor=red]; - 59 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; - 60 [label="Exit function " style="filled" fillcolor=red]; + 56 [label="Enter property" style="filled" fillcolor=red]; + 57 [label="Access variable R|/a|"]; + 58 [label="Smart cast: R|/a|"]; + 59 [label="Access variable R|/A.index|"]; + 60 [label="Exit property" style="filled" fillcolor=red]; } 61 [label="Exit class " style="filled" fillcolor=red]; } @@ -207,24 +207,24 @@ digraph smartcastInByClause_kt { 43 -> {62} [style=dotted]; 43 -> {44} [style=dashed]; 44 -> {45}; - 44 -> {53 58 67} [color=red]; + 44 -> {48 56 67} [color=red]; 44 -> {61} [style=dotted]; - 44 -> {45 53 58} [style=dashed]; + 44 -> {45 48 56} [style=dashed]; 45 -> {46}; 46 -> {47}; - 47 -> {48}; + 47 -> {48} [color=green]; + 47 -> {61} [color=red]; 48 -> {49}; 49 -> {50}; 50 -> {51}; 51 -> {52}; - 52 -> {53} [color=green]; - 52 -> {61} [color=red]; + 52 -> {53}; 53 -> {54}; 54 -> {55}; - 55 -> {56}; + 55 -> {56} [color=green]; + 55 -> {61} [color=red]; 56 -> {57}; - 57 -> {58} [color=green]; - 57 -> {61} [color=red]; + 57 -> {58}; 58 -> {59}; 59 -> {60}; 60 -> {61}; diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToNothing.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToNothing.dot index 3d5ff2c5beb..0142d403d6d 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToNothing.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToNothing.dot @@ -133,21 +133,21 @@ digraph smartcastToNothing_kt { 43 [label="Enter class A" style="filled" fillcolor=red]; subgraph cluster_13 { color=blue - 44 [label="Enter property" style="filled" fillcolor=red]; - 45 [label="Const: Int(1)"]; - 46 [label="Exit property" style="filled" fillcolor=red]; + 44 [label="Enter function " style="filled" fillcolor=red]; + 45 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 46 [label="Exit function " style="filled" fillcolor=red]; } subgraph cluster_14 { color=blue 47 [label="Enter property" style="filled" fillcolor=red]; - 48 [label="Const: Boolean(true)"]; + 48 [label="Const: Int(1)"]; 49 [label="Exit property" style="filled" fillcolor=red]; } subgraph cluster_15 { color=blue - 50 [label="Enter function " style="filled" fillcolor=red]; - 51 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; - 52 [label="Exit function " style="filled" fillcolor=red]; + 50 [label="Enter property" style="filled" fillcolor=red]; + 51 [label="Const: Boolean(true)"]; + 52 [label="Exit property" style="filled" fillcolor=red]; } 53 [label="Exit class A" style="filled" fillcolor=red]; } 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 096e62fe593..a3763898a5b 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/stability/overridenOpenVal.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/stability/overridenOpenVal.dot @@ -15,15 +15,15 @@ digraph overridenOpenVal_kt { 2 [label="Enter class A" style="filled" fillcolor=red]; subgraph cluster_2 { color=blue - 3 [label="Enter property" style="filled" fillcolor=red]; - 4 [label="Access variable R|/x|"]; - 5 [label="Exit property" style="filled" fillcolor=red]; + 3 [label="Enter function " style="filled" fillcolor=red]; + 4 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 5 [label="Exit function " style="filled" fillcolor=red]; } subgraph cluster_3 { color=blue - 6 [label="Enter function " style="filled" fillcolor=red]; - 7 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; - 8 [label="Exit function " style="filled" fillcolor=red]; + 6 [label="Enter property" style="filled" fillcolor=red]; + 7 [label="Access variable R|/x|"]; + 8 [label="Exit property" style="filled" fillcolor=red]; } 9 [label="Exit class A" style="filled" fillcolor=red]; } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/bad/callsInPlace/inAnonymousObject.dot b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/bad/callsInPlace/inAnonymousObject.dot index 12d1f6a0644..e1242f26938 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/bad/callsInPlace/inAnonymousObject.dot +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/bad/callsInPlace/inAnonymousObject.dot @@ -27,27 +27,27 @@ digraph inAnonymousObject_kt { 7 [label="Enter class " style="filled" fillcolor=red]; subgraph cluster_5 { color=blue - 8 [label="Enter property" style="filled" fillcolor=red]; - 9 [label="Access variable R|/a|"]; - 10 [label="Exit property" style="filled" fillcolor=red]; + 8 [label="Enter function " style="filled" fillcolor=red]; + 9 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 10 [label="Exit function " style="filled" fillcolor=red]; } subgraph cluster_6 { color=blue - 11 [label="Enter init block" style="filled" fillcolor=red]; - subgraph cluster_7 { - color=blue - 12 [label="Enter block"]; - 13 [label="Access variable R|/b|"]; - 14 [label="Assignment: R|/.leaked|"]; - 15 [label="Exit block"]; - } - 16 [label="Exit init block" style="filled" fillcolor=red]; + 11 [label="Enter property" style="filled" fillcolor=red]; + 12 [label="Access variable R|/a|"]; + 13 [label="Exit property" style="filled" fillcolor=red]; } - subgraph cluster_8 { + subgraph cluster_7 { color=blue - 17 [label="Enter function " style="filled" fillcolor=red]; - 18 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; - 19 [label="Exit function " style="filled" fillcolor=red]; + 14 [label="Enter init block" style="filled" fillcolor=red]; + subgraph cluster_8 { + color=blue + 15 [label="Enter block"]; + 16 [label="Access variable R|/b|"]; + 17 [label="Assignment: R|/.leaked|"]; + 18 [label="Exit block"]; + } + 19 [label="Exit init block" style="filled" fillcolor=red]; } 20 [label="Exit class " style="filled" fillcolor=red]; } @@ -94,20 +94,20 @@ digraph inAnonymousObject_kt { 6 -> {21} [style=dotted]; 6 -> {7} [style=dashed]; 7 -> {8}; - 7 -> {11 17 32} [color=red]; + 7 -> {11 14 32} [color=red]; 7 -> {20} [style=dotted]; - 7 -> {8 11 17} [style=dashed]; + 7 -> {8 11 14} [style=dashed]; 8 -> {9}; 9 -> {10}; 10 -> {11} [color=green]; 10 -> {20} [color=red]; 11 -> {12}; 12 -> {13}; - 13 -> {14}; + 13 -> {14} [color=green]; + 13 -> {20} [color=red]; 14 -> {15}; 15 -> {16}; - 16 -> {17} [color=green]; - 16 -> {20} [color=red]; + 16 -> {17}; 17 -> {18}; 18 -> {19}; 19 -> {20}; diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateWithAnonymousObject.dot b/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateWithAnonymousObject.dot index 9abc438fe2d..0ac8f6985ce 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateWithAnonymousObject.dot +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateWithAnonymousObject.dot @@ -89,153 +89,153 @@ digraph delegateWithAnonymousObject_kt { 25 [label="Enter class IssuesListUserProfile" style="filled" fillcolor=red]; subgraph cluster_10 { color=blue - 26 [label="Enter property" style="filled" fillcolor=red]; - subgraph cluster_11 { - color=blue - 27 [label="Function call arguments enter"]; - 28 [label="Postponed enter to lambda"]; - subgraph cluster_12 { - color=blue - 29 [label="Enter function " style="filled" fillcolor=red]; - subgraph cluster_13 { - color=blue - 30 [label="Enter block"]; - 31 [label="Enter anonymous object"]; - subgraph cluster_14 { - color=blue - 32 [label="Enter class " style="filled" fillcolor=red]; - subgraph cluster_15 { - color=blue - 33 [label="Enter function " style="filled" fillcolor=red]; - 34 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; - 35 [label="Exit function " style="filled" fillcolor=red]; - } - 36 [label="Exit class " style="filled" fillcolor=red]; - } - 37 [label="Exit anonymous object expression"]; - 38 [label="Exit block"]; - } - 39 [label="Exit function " style="filled" fillcolor=red]; - } - subgraph cluster_16 { - color=blue - 40 [label="Enter function setValue" style="filled" fillcolor=red]; - subgraph cluster_17 { - color=blue - 41 [label="Enter block"]; - subgraph cluster_18 { - color=blue - 42 [label="Function call arguments enter"]; - subgraph cluster_19 { - color=blue - 43 [label="Function call arguments enter"]; - 44 [label="Function call arguments exit"]; - } - 45 [label="Function call: R|/IssueListView.IssueListView|()" style="filled" fillcolor=yellow]; - 46 [label="Access variable R|/value|"]; - 47 [label="Function call arguments exit"]; - } - 48 [label="Function call: R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(...)" style="filled" fillcolor=yellow]; - 49 [label="Jump: ^setValue R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(R|/value|)"]; - 50 [label="Stub" style="filled" fillcolor=gray]; - 51 [label="Exit block" style="filled" fillcolor=gray]; - } - 52 [label="Exit function setValue" style="filled" fillcolor=red]; - } - subgraph cluster_20 { - color=blue - 53 [label="Enter function getValue" style="filled" fillcolor=red]; - subgraph cluster_21 { - color=blue - 54 [label="Enter block"]; - subgraph cluster_22 { - color=blue - 55 [label="Function call arguments enter"]; - 56 [label="Function call arguments exit"]; - } - 57 [label="Function call: R|/IssueListView.IssueListView|()" style="filled" fillcolor=yellow]; - 58 [label="Jump: ^getValue R|/IssueListView.IssueListView|()"]; - 59 [label="Stub" style="filled" fillcolor=gray]; - 60 [label="Exit block" style="filled" fillcolor=gray]; - } - 61 [label="Exit function getValue" style="filled" fillcolor=red]; - } - 62 [label="Function call arguments exit"]; - } - 63 [label="Postponed exit from lambda"]; - 64 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|(...)" style="filled" fillcolor=yellow]; - subgraph cluster_23 { - color=blue - 65 [label="Function call arguments enter"]; - 66 [label="Function call arguments exit"]; - } - 67 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|(...).R?C|special/error|(...)" style="filled" fillcolor=yellow]; - 68 [label="Exit property delegate" style="filled" fillcolor=yellow]; - 69 [label="Exit property" style="filled" fillcolor=red]; + 26 [label="Enter function " style="filled" fillcolor=red]; + 27 [label="Delegated constructor call: super|>()" style="filled" fillcolor=yellow]; + 28 [label="Exit function " style="filled" fillcolor=red]; } - subgraph cluster_24 { + subgraph cluster_11 { color=blue - 70 [label="Enter function " style="filled" fillcolor=red]; - 71 [label="Delegated constructor call: super|>()" style="filled" fillcolor=yellow]; - 72 [label="Exit function " style="filled" fillcolor=red]; + 29 [label="Enter property" style="filled" fillcolor=red]; + subgraph cluster_12 { + color=blue + 30 [label="Function call arguments enter"]; + 31 [label="Postponed enter to lambda"]; + subgraph cluster_13 { + color=blue + 32 [label="Enter function " style="filled" fillcolor=red]; + subgraph cluster_14 { + color=blue + 33 [label="Enter block"]; + 34 [label="Enter anonymous object"]; + subgraph cluster_15 { + color=blue + 35 [label="Enter class " style="filled" fillcolor=red]; + subgraph cluster_16 { + color=blue + 36 [label="Enter function " style="filled" fillcolor=red]; + 37 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 38 [label="Exit function " style="filled" fillcolor=red]; + } + 39 [label="Exit class " style="filled" fillcolor=red]; + } + 40 [label="Exit anonymous object expression"]; + 41 [label="Exit block"]; + } + 42 [label="Exit function " style="filled" fillcolor=red]; + } + subgraph cluster_17 { + color=blue + 43 [label="Enter function setValue" style="filled" fillcolor=red]; + subgraph cluster_18 { + color=blue + 44 [label="Enter block"]; + subgraph cluster_19 { + color=blue + 45 [label="Function call arguments enter"]; + subgraph cluster_20 { + color=blue + 46 [label="Function call arguments enter"]; + 47 [label="Function call arguments exit"]; + } + 48 [label="Function call: R|/IssueListView.IssueListView|()" style="filled" fillcolor=yellow]; + 49 [label="Access variable R|/value|"]; + 50 [label="Function call arguments exit"]; + } + 51 [label="Function call: R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(...)" style="filled" fillcolor=yellow]; + 52 [label="Jump: ^setValue R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(R|/value|)"]; + 53 [label="Stub" style="filled" fillcolor=gray]; + 54 [label="Exit block" style="filled" fillcolor=gray]; + } + 55 [label="Exit function setValue" style="filled" fillcolor=red]; + } + subgraph cluster_21 { + color=blue + 56 [label="Enter function getValue" style="filled" fillcolor=red]; + subgraph cluster_22 { + color=blue + 57 [label="Enter block"]; + subgraph cluster_23 { + color=blue + 58 [label="Function call arguments enter"]; + 59 [label="Function call arguments exit"]; + } + 60 [label="Function call: R|/IssueListView.IssueListView|()" style="filled" fillcolor=yellow]; + 61 [label="Jump: ^getValue R|/IssueListView.IssueListView|()"]; + 62 [label="Stub" style="filled" fillcolor=gray]; + 63 [label="Exit block" style="filled" fillcolor=gray]; + } + 64 [label="Exit function getValue" style="filled" fillcolor=red]; + } + 65 [label="Function call arguments exit"]; + } + 66 [label="Postponed exit from lambda"]; + 67 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|(...)" style="filled" fillcolor=yellow]; + subgraph cluster_24 { + color=blue + 68 [label="Function call arguments enter"]; + 69 [label="Function call arguments exit"]; + } + 70 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|(...).R?C|special/error|(...)" style="filled" fillcolor=yellow]; + 71 [label="Exit property delegate" style="filled" fillcolor=yellow]; + 72 [label="Exit property" style="filled" fillcolor=red]; } 73 [label="Exit class IssuesListUserProfile" style="filled" fillcolor=red]; } 25 -> {26} [color=green]; 25 -> {73} [style=dotted]; - 25 -> {26 70} [style=dashed]; + 25 -> {26 29} [style=dashed]; 26 -> {27}; 27 -> {28}; - 28 -> {29 62 63}; - 28 -> {29} [style=dashed]; + 28 -> {29} [color=green]; 29 -> {30}; 30 -> {31}; - 31 -> {32}; - 31 -> {37} [style=dotted]; + 31 -> {32 65 66}; 31 -> {32} [style=dashed]; 32 -> {33}; - 32 -> {40 53} [color=red]; - 32 -> {36} [style=dotted]; - 32 -> {33} [style=dashed]; 33 -> {34}; 34 -> {35}; + 34 -> {40} [style=dotted]; + 34 -> {35} [style=dashed]; 35 -> {36}; + 35 -> {43 56} [color=red]; + 35 -> {39} [style=dotted]; + 35 -> {36} [style=dashed]; 36 -> {37}; - 36 -> {40 53} [color=green]; - 36 -> {40 53} [style=dashed]; 37 -> {38}; 38 -> {39}; + 39 -> {40}; + 39 -> {43 56} [color=green]; + 39 -> {43 56} [style=dashed]; 40 -> {41}; 41 -> {42}; - 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]; - 53 -> {54}; - 54 -> {55}; - 55 -> {56}; + 49 -> {50}; + 50 -> {51}; + 51 -> {52}; + 52 -> {55}; + 52 -> {53} [style=dotted]; + 53 -> {54} [style=dotted]; + 54 -> {55} [style=dotted]; 56 -> {57}; 57 -> {58}; - 58 -> {61}; - 58 -> {59} [style=dotted]; - 59 -> {60} [style=dotted]; - 60 -> {61} [style=dotted]; - 62 -> {64}; - 63 -> {64} [color=green]; - 63 -> {68} [color=red label="Postponed"]; - 64 -> {65}; - 65 -> {66}; - 66 -> {67}; + 58 -> {59}; + 59 -> {60}; + 60 -> {61}; + 61 -> {64}; + 61 -> {62} [style=dotted]; + 62 -> {63} [style=dotted]; + 63 -> {64} [style=dotted]; + 65 -> {67}; + 66 -> {67} [color=green]; + 66 -> {71} [color=red label="Postponed"]; 67 -> {68}; 68 -> {69}; - 69 -> {70} [color=green]; + 69 -> {70}; 70 -> {71}; 71 -> {72}; 72 -> {73} [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 81163b0cfb7..ed73246872a 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.dot +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.dot @@ -61,15 +61,15 @@ digraph plusAssignWithLambdaInRhs_kt { 19 [label="Enter class A" style="filled" fillcolor=red]; subgraph cluster_6 { color=blue - 20 [label="Enter property" style="filled" fillcolor=red]; - 21 [label="Access variable R|/executor|"]; - 22 [label="Exit property" style="filled" fillcolor=red]; + 20 [label="Enter function " style="filled" fillcolor=red]; + 21 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; + 22 [label="Exit function " style="filled" fillcolor=red]; } subgraph cluster_7 { color=blue - 23 [label="Enter function " style="filled" fillcolor=red]; - 24 [label="Delegated constructor call: super()" style="filled" fillcolor=yellow]; - 25 [label="Exit function " style="filled" fillcolor=red]; + 23 [label="Enter property" style="filled" fillcolor=red]; + 24 [label="Access variable R|/executor|"]; + 25 [label="Exit property" style="filled" fillcolor=red]; } 26 [label="Exit class A" style="filled" fillcolor=red]; } 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 92f74315328..992bf42bb12 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 @@ -436,8 +436,18 @@ class ControlFlowGraphBuilder { // ----------------------------------- Classes ----------------------------------- - private fun FirClass.firstInPlaceInitializedMember(): FirDeclaration? = - declarations.find { it is FirControlFlowGraphOwner && it !is FirConstructor && it.isUsedInControlFlowGraphBuilderForClass } + /** + * The first in-place initializer is either: + * 1. The primary constructor. + * 2. The first property or anonymous initializer. + */ + private fun FirClass.firstInPlaceInitializer(): FirDeclaration? { + return declarations.find { + it is FirControlFlowGraphOwner && + (it !is FirConstructor || it.isPrimary) && + it.isUsedInControlFlowGraphBuilderForClass + } + } private inline fun List.forEachGraphOwner(block: (FirControlFlowGraphOwner) -> Unit) { for (member in this) { @@ -486,14 +496,19 @@ class ControlFlowGraphBuilder { } if (enterNode.previousNodes.isNotEmpty()) { - val firstInPlace = klass.firstInPlaceInitializedMember() + val firstInPlace = klass.firstInPlaceInitializer() klass.declarations.forEachGraphOwner { - // For local classes, the first in-place initializer, all constructors when there are no in-place initializers, or any - // this-delegating constructors should have a forward edge from ClassEnterNode, while everything else should have a - // DFG-only forward edge. - val kind = if (firstInPlace == it || - (it is FirConstructor && (firstInPlace == null || it.delegatedConstructor?.isThis == true)) - ) EdgeKind.Forward else EdgeKind.DfgForward + // For local classes, + // - the first in-place initializer, + // - all constructors when there are no in-place initializers, + // - or any this-delegating constructors, + // should have a forward edge from ClassEnterNode. + // Everything else should have a DFG-only forward edge. + val kind = when { + firstInPlace == it -> EdgeKind.Forward + it is FirConstructor && (firstInPlace == null || it.delegatedConstructor?.isThis == true) -> EdgeKind.Forward + else -> EdgeKind.DfgForward + } enterToLocalClassesMembers[(it as FirDeclaration).symbol] = enterNode to kind } } @@ -521,13 +536,23 @@ class ControlFlowGraphBuilder { } val isLocalClass = klass.isLocal + var primaryConstructor: ControlFlowGraph? = null val calledInPlace = mutableListOf() + val secondaryConstructors = mutableMapOf() val calledLater = mutableListOf() - val constructors = mutableMapOf() klass.declarations.forEachGraphOwner { val graph = it.controlFlowGraphReference?.controlFlowGraph ?: return@forEachGraphOwner when (it) { - is FirConstructor -> constructors[it] = graph + is FirConstructor -> when { + it.isPrimary -> { + // The primary constructor is treated as an in-place initializer since it is always called, but a specific + // reference needs to be saved to inject into any secondary constructor delegation. + calledInPlace.add(graph) + primaryConstructor = graph + } + else -> secondaryConstructors[it] = graph + } + is FirPropertyAccessor, is FirFunction, is FirClass -> if (isLocalClass) { calledLater.add(graph) } @@ -536,22 +561,29 @@ class ControlFlowGraphBuilder { } } + // Create primary constructor and in-place initializer edges. + val firstInPlaceEnter = calledInPlace.firstOrNull()?.enterNode val lastInPlaceExit = calledInPlace.fold<_, CFGNode<*>>(enterNode) { lastNode, graph -> // In local classes, we already have control flow (+ data flow) edge from `enterNode` - // to first in-place initializer. + // to primary constructor or first in-place initializer. if (lastNode !== enterNode || lastNode.previousNodes.isEmpty()) { addEdgeToSubGraph(lastNode, graph.enterNode) } graph.exitNode } - if (exitNode.isUnion) { - // => this is an anonymous object => there's only one constructor => can use `exitNode` - // to unify data flow from all in-place-called members, including said constructor. - for (graph in calledInPlace) { - addEdge(graph.exitNode, exitNode, preferredKind = EdgeKind.DfgForward) - } + + for (graph in calledInPlace) { + EdgeKind.forward( + // => this class has a primary constructor => the last in-place initializer must have a + // control flow edge to the exit node. + usedInCfa = primaryConstructor != null && graph.exitNode == lastInPlaceExit, + // => this is an anonymous object => there's only one constructor => can use `exitNode` + // to unify data flow from all in-place-called members, including said constructor. + usedInDfa = exitNode.isUnion, + )?.let { edgeKind -> addEdge(graph.exitNode, exitNode, preferredKind = edgeKind) } } + // Create secondary constructor edges. val parentConstructors = mutableMapOf() fun FirConstructor.parentConstructor(): FirConstructor? = parentConstructors.getOrPutNullable(this) { // Break cycles in some way; there will be errors on delegated constructor calls in that case. @@ -561,15 +593,23 @@ class ControlFlowGraphBuilder { ?.takeIf { parent -> this !in generateSequence(parent) { it.parentConstructor() } } } - for ((ctor, graph) in constructors) { - val delegatedConstructorGraph = constructors[ctor.parentConstructor()] - if (delegatedConstructorGraph != null) { + fun getDelegateNodes(ctor: FirConstructor): Pair?, CFGNode?> { + val parentConstructor = ctor.parentConstructor() + val secondaryGraph = secondaryConstructors[parentConstructor] + return when { + secondaryGraph != null -> (firstInPlaceEnter ?: secondaryGraph.enterNode) to secondaryGraph.exitNode + primaryConstructor != null && primaryConstructor == parentConstructor?.controlFlowGraphReference?.controlFlowGraph -> firstInPlaceEnter to lastInPlaceExit + else -> null to null + } + } + + for ((ctor, graph) in secondaryConstructors) { + val (delegatedEnter, delegatedExit) = getDelegateNodes(ctor) + if (delegatedEnter != null && delegatedExit != null) { // Inject delegated constructor and other in-place initializer sub-graphs after the delegated constructor call node. This // ensures property initialization and use is calculated correctly when there are complex calculations for the arguments to // the delegated constructor. - val delegatedConstructorEnter = calledInPlace.firstOrNull()?.enterNode ?: delegatedConstructorGraph.enterNode - val delegatedConstructorExit = delegatedConstructorGraph.exitNode val delegatedConstructorCall = graph.nodes.single { it is DelegatedConstructorCallNode } val edgeLabel = graph.exitNode as FunctionExitNode @@ -578,9 +618,9 @@ class ControlFlowGraphBuilder { if (!isLocalClass) addEdgeToSubGraph(enterNode, graph.enterNode) - addEdgeToSubGraph(delegatedConstructorCall, delegatedConstructorEnter, label = edgeLabel) + addEdgeToSubGraph(delegatedConstructorCall, delegatedEnter, label = edgeLabel) for (node in followingNodes) { - addEdge(delegatedConstructorExit, node, preferredKind = EdgeKind.CfgForward, label = edgeLabel) + addEdge(delegatedExit, node, preferredKind = EdgeKind.CfgForward, label = edgeLabel) addEdge(delegatedConstructorCall, node, preferredKind = EdgeKind.DfgForward) } } else if (lastInPlaceExit !== enterNode || lastInPlaceExit.previousNodes.isEmpty()) { @@ -591,7 +631,7 @@ class ControlFlowGraphBuilder { addEdge(graph.exitNode, exitNode, preferredKind = if (exitNode.isUnion) EdgeKind.Forward else EdgeKind.CfgForward) } - if (constructors.isEmpty()) { + if (primaryConstructor == null && secondaryConstructors.isEmpty()) { // Interfaces have no constructors, add an edge from enter to exit so that methods aren't marked as dead. addEdge(enterNode, exitNode, preferredKind = EdgeKind.CfgForward) } else { @@ -605,7 +645,7 @@ class ControlFlowGraphBuilder { addEdgeToSubGraph(exitNode, graph.enterNode) } - enterNode.subGraphs = calledInPlace + constructors.values + enterNode.subGraphs = calledInPlace + secondaryConstructors.values exitNode.subGraphs = calledLater return exitNode.takeIf { it.isUnion } to popGraph() } diff --git a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt index 5ca965ef268..021b0cbd402 100644 --- a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt +++ b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt @@ -122,7 +122,19 @@ enum class EdgeKind( DfgForward(usedInDfa = true, usedInDeadDfa = true, usedInCfa = false, isBack = false, isDead = false), CfgForward(usedInDfa = false, usedInDeadDfa = false, usedInCfa = true, isBack = false, isDead = false), CfgBackward(usedInDfa = false, usedInDeadDfa = false, usedInCfa = true, isBack = true, isDead = false), - DeadBackward(usedInDfa = false, usedInDeadDfa = false, usedInCfa = true, isBack = true, isDead = true) + DeadBackward(usedInDfa = false, usedInDeadDfa = false, usedInCfa = true, isBack = true, isDead = true), + ; + + companion object { + fun forward(usedInCfa: Boolean = false, usedInDfa: Boolean = false): EdgeKind? { + return when { + usedInCfa && usedInDfa -> Forward + usedInCfa -> CfgForward + usedInDfa -> DfgForward + else -> null + } + } + } } private val CFGNode<*>.previousNodeCount diff --git a/compiler/testData/codegen/box/smartCasts/kt44814.dot b/compiler/testData/codegen/box/smartCasts/kt44814.dot index 623ed1ec282..c68767250c1 100644 --- a/compiler/testData/codegen/box/smartCasts/kt44814.dot +++ b/compiler/testData/codegen/box/smartCasts/kt44814.dot @@ -51,27 +51,27 @@ digraph kt44814_kt { 12 [label="Enter class FirPsiSourceElement [2]" style="filled" fillcolor=red]; subgraph cluster_6 { color=blue - 13 [label="Enter property [3]" style="filled" fillcolor=red]; - 14 [label="Access variable R|/psi| [3]"]; - 15 [label="Exit property [3]" style="filled" fillcolor=red]; + 13 [label="Enter function [3]" style="filled" fillcolor=red]; + 14 [label="Delegated constructor call: super() [3]" style="filled" fillcolor=yellow]; + 15 [label="Exit function [3]" style="filled" fillcolor=red]; } subgraph cluster_7 { color=blue 16 [label="Enter property [3]" style="filled" fillcolor=red]; - 17 [label="Access variable R|/lighterASTNode| [3]"]; + 17 [label="Access variable R|/psi| [3]"]; 18 [label="Exit property [3]" style="filled" fillcolor=red]; } subgraph cluster_8 { color=blue 19 [label="Enter property [3]" style="filled" fillcolor=red]; - 20 [label="Access variable R|/treeStructure| [3]"]; + 20 [label="Access variable R|/lighterASTNode| [3]"]; 21 [label="Exit property [3]" style="filled" fillcolor=red]; } subgraph cluster_9 { color=blue - 22 [label="Enter function [3]" style="filled" fillcolor=red]; - 23 [label="Delegated constructor call: super() [3]" style="filled" fillcolor=yellow]; - 24 [label="Exit function [3]" style="filled" fillcolor=red]; + 22 [label="Enter property [3]" style="filled" fillcolor=red]; + 23 [label="Access variable R|/treeStructure| [3]"]; + 24 [label="Exit property [3]" style="filled" fillcolor=red]; } 25 [label="Exit class FirPsiSourceElement [2]" style="filled" fillcolor=red]; } @@ -96,21 +96,21 @@ digraph kt44814_kt { 26 [label="Enter class FirLightSourceElement [2]" style="filled" fillcolor=red]; subgraph cluster_11 { color=blue - 27 [label="Enter property [3]" style="filled" fillcolor=red]; - 28 [label="Access variable R|/lighterASTNode| [3]"]; - 29 [label="Exit property [3]" style="filled" fillcolor=red]; + 27 [label="Enter function [3]" style="filled" fillcolor=red]; + 28 [label="Delegated constructor call: super() [3]" style="filled" fillcolor=yellow]; + 29 [label="Exit function [3]" style="filled" fillcolor=red]; } subgraph cluster_12 { color=blue 30 [label="Enter property [3]" style="filled" fillcolor=red]; - 31 [label="Access variable R|/treeStructure| [3]"]; + 31 [label="Access variable R|/lighterASTNode| [3]"]; 32 [label="Exit property [3]" style="filled" fillcolor=red]; } subgraph cluster_13 { color=blue - 33 [label="Enter function [3]" style="filled" fillcolor=red]; - 34 [label="Delegated constructor call: super() [3]" style="filled" fillcolor=yellow]; - 35 [label="Exit function [3]" style="filled" fillcolor=red]; + 33 [label="Enter property [3]" style="filled" fillcolor=red]; + 34 [label="Access variable R|/treeStructure| [3]"]; + 35 [label="Exit property [3]" style="filled" fillcolor=red]; } 36 [label="Exit class FirLightSourceElement [2]" style="filled" fillcolor=red]; } @@ -168,55 +168,55 @@ digraph kt44814_kt { 47 [label="Enter class LighterASTNode [2]" style="filled" fillcolor=red]; subgraph cluster_19 { color=blue - 48 [label="Enter property [3]" style="filled" fillcolor=red]; - 49 [label="Access variable R|/_children| [3]"]; - 50 [label="Exit property [3]" style="filled" fillcolor=red]; - } - subgraph cluster_20 { - color=blue - 51 [label="Enter property [3]" style="filled" fillcolor=red]; - 52 [label="Access qualifier /TokenType [3]"]; - 53 [label="Access variable R|/TokenType.Companion.MODIFIER_LIST| [3]"]; - 54 [label="Exit property [3]" style="filled" fillcolor=red]; - } - subgraph cluster_21 { - color=blue - 55 [label="Enter function [3]" style="filled" fillcolor=red]; - 56 [label="Enter default value of _children [3]"]; - subgraph cluster_22 { + 48 [label="Enter function [3]" style="filled" fillcolor=red]; + 49 [label="Enter default value of _children [3]"]; + subgraph cluster_20 { color=blue - 57 [label="Enter default value of _children [4]" style="filled" fillcolor=red]; - subgraph cluster_23 { + 50 [label="Enter default value of _children [4]" style="filled" fillcolor=red]; + subgraph cluster_21 { color=blue - 58 [label="Function call arguments enter [4]"]; - 59 [label="Function call arguments exit [4]"]; + 51 [label="Function call arguments enter [4]"]; + 52 [label="Function call arguments exit [4]"]; } - 60 [label="Function call: R|kotlin/collections/emptyList|() [4]" style="filled" fillcolor=yellow]; - 61 [label="Exit default value of _children [4]" style="filled" fillcolor=red]; + 53 [label="Function call: R|kotlin/collections/emptyList|() [4]" style="filled" fillcolor=yellow]; + 54 [label="Exit default value of _children [4]" style="filled" fillcolor=red]; } - 62 [label="Exit default value of _children [3]"]; - 63 [label="Delegated constructor call: super() [3]" style="filled" fillcolor=yellow]; - 64 [label="Exit function [3]" style="filled" fillcolor=red]; + 55 [label="Exit default value of _children [3]"]; + 56 [label="Delegated constructor call: super() [3]" style="filled" fillcolor=yellow]; + 57 [label="Exit function [3]" style="filled" fillcolor=red]; + } + subgraph cluster_22 { + color=blue + 58 [label="Enter property [3]" style="filled" fillcolor=red]; + 59 [label="Access variable R|/_children| [3]"]; + 60 [label="Exit property [3]" style="filled" fillcolor=red]; + } + subgraph cluster_23 { + color=blue + 61 [label="Enter property [3]" style="filled" fillcolor=red]; + 62 [label="Access qualifier /TokenType [3]"]; + 63 [label="Access variable R|/TokenType.Companion.MODIFIER_LIST| [3]"]; + 64 [label="Exit property [3]" style="filled" fillcolor=red]; } 65 [label="Exit class LighterASTNode [2]" style="filled" fillcolor=red]; } 47 -> {48} [color=green]; 47 -> {65} [style=dotted]; - 47 -> {48 51 55} [style=dashed]; + 47 -> {48 58 61} [style=dashed]; 48 -> {49}; - 49 -> {50}; - 50 -> {51} [color=green]; + 49 -> {50 55}; + 49 -> {50} [style=dashed]; + 50 -> {51}; 51 -> {52}; 52 -> {53}; 53 -> {54}; - 54 -> {55} [color=green]; + 54 -> {55}; 55 -> {56}; - 56 -> {57 62}; - 56 -> {57} [style=dashed]; - 57 -> {58}; + 56 -> {57}; + 57 -> {58} [color=green]; 58 -> {59}; 59 -> {60}; - 60 -> {61}; + 60 -> {61} [color=green]; 61 -> {62}; 62 -> {63}; 63 -> {64}; @@ -266,31 +266,31 @@ digraph kt44814_kt { 78 [label="Enter class Companion [3]" style="filled" fillcolor=red]; subgraph cluster_29 { color=blue - 79 [label="Enter property [4]" style="filled" fillcolor=red]; - subgraph cluster_30 { - color=blue - 80 [label="Function call arguments enter [4]"]; - 81 [label="Function call arguments exit [4]"]; - } - 82 [label="Function call: R|/TokenType.TokenType|() [4]" style="filled" fillcolor=yellow]; - 83 [label="Exit property [4]" style="filled" fillcolor=red]; + 79 [label="Enter function [4]" style="filled" fillcolor=red]; + 80 [label="Delegated constructor call: super() [4]" style="filled" fillcolor=yellow]; + 81 [label="Exit function [4]" style="filled" fillcolor=red]; } - subgraph cluster_31 { + subgraph cluster_30 { color=blue - 84 [label="Enter function [4]" style="filled" fillcolor=red]; - 85 [label="Delegated constructor call: super() [4]" style="filled" fillcolor=yellow]; - 86 [label="Exit function [4]" style="filled" fillcolor=red]; + 82 [label="Enter property [4]" style="filled" fillcolor=red]; + subgraph cluster_31 { + color=blue + 83 [label="Function call arguments enter [4]"]; + 84 [label="Function call arguments exit [4]"]; + } + 85 [label="Function call: R|/TokenType.TokenType|() [4]" style="filled" fillcolor=yellow]; + 86 [label="Exit property [4]" style="filled" fillcolor=red]; } 87 [label="Exit class Companion [3]" style="filled" fillcolor=red]; } 78 -> {79} [color=green]; 78 -> {87} [style=dotted]; - 78 -> {79 84} [style=dashed]; + 78 -> {79 82} [style=dashed]; 79 -> {80}; 80 -> {81}; - 81 -> {82}; + 81 -> {82} [color=green]; 82 -> {83}; - 83 -> {84} [color=green]; + 83 -> {84}; 84 -> {85}; 85 -> {86}; 86 -> {87} [color=green]; @@ -336,31 +336,31 @@ digraph kt44814_kt { 98 [label="Enter class KtModifierListOwner [2]" style="filled" fillcolor=red]; subgraph cluster_37 { color=blue - 99 [label="Enter property [3]" style="filled" fillcolor=red]; - subgraph cluster_38 { - color=blue - 100 [label="Function call arguments enter [3]"]; - 101 [label="Function call arguments exit [3]"]; - } - 102 [label="Function call: R|/KtModifierList.KtModifierList|() [3]" style="filled" fillcolor=yellow]; - 103 [label="Exit property [3]" style="filled" fillcolor=red]; + 99 [label="Enter function [3]" style="filled" fillcolor=red]; + 100 [label="Delegated constructor call: super() [3]" style="filled" fillcolor=yellow]; + 101 [label="Exit function [3]" style="filled" fillcolor=red]; } - subgraph cluster_39 { + subgraph cluster_38 { color=blue - 104 [label="Enter function [3]" style="filled" fillcolor=red]; - 105 [label="Delegated constructor call: super() [3]" style="filled" fillcolor=yellow]; - 106 [label="Exit function [3]" style="filled" fillcolor=red]; + 102 [label="Enter property [3]" style="filled" fillcolor=red]; + subgraph cluster_39 { + color=blue + 103 [label="Function call arguments enter [3]"]; + 104 [label="Function call arguments exit [3]"]; + } + 105 [label="Function call: R|/KtModifierList.KtModifierList|() [3]" style="filled" fillcolor=yellow]; + 106 [label="Exit property [3]" style="filled" fillcolor=red]; } 107 [label="Exit class KtModifierListOwner [2]" style="filled" fillcolor=red]; } 98 -> {99} [color=green]; 98 -> {107} [style=dotted]; - 98 -> {99 104} [style=dashed]; + 98 -> {99 102} [style=dashed]; 99 -> {100}; 100 -> {101}; - 101 -> {102}; + 101 -> {102} [color=green]; 102 -> {103}; - 103 -> {104} [color=green]; + 103 -> {104}; 104 -> {105}; 105 -> {106}; 106 -> {107} [color=green]; @@ -370,21 +370,21 @@ digraph kt44814_kt { 108 [label="Enter class FirModifier [2]" style="filled" fillcolor=red]; subgraph cluster_41 { color=blue - 109 [label="Enter property [3]" style="filled" fillcolor=red]; - 110 [label="Access variable R|/node| [3]"]; - 111 [label="Exit property [3]" style="filled" fillcolor=red]; + 109 [label="Enter function [3]" style="filled" fillcolor=red]; + 110 [label="Delegated constructor call: super() [3]" style="filled" fillcolor=yellow]; + 111 [label="Exit function [3]" style="filled" fillcolor=red]; } subgraph cluster_42 { color=blue 112 [label="Enter property [3]" style="filled" fillcolor=red]; - 113 [label="Access variable R|/token| [3]"]; + 113 [label="Access variable R|/node| [3]"]; 114 [label="Exit property [3]" style="filled" fillcolor=red]; } subgraph cluster_43 { color=blue - 115 [label="Enter function [3]" style="filled" fillcolor=red]; - 116 [label="Delegated constructor call: super() [3]" style="filled" fillcolor=yellow]; - 117 [label="Exit function [3]" style="filled" fillcolor=red]; + 115 [label="Enter property [3]" style="filled" fillcolor=red]; + 116 [label="Access variable R|/token| [3]"]; + 117 [label="Exit property [3]" style="filled" fillcolor=red]; } 118 [label="Exit class FirModifier [2]" style="filled" fillcolor=red]; } @@ -428,28 +428,28 @@ digraph kt44814_kt { 126 [label="Enter class FirLightModifier [3]" style="filled" fillcolor=red]; subgraph cluster_47 { color=blue - 127 [label="Enter property [4]" style="filled" fillcolor=red]; - 128 [label="Access variable R|/tree| [4]"]; - 129 [label="Exit property [4]" style="filled" fillcolor=red]; + 127 [label="Enter function [4]" style="filled" fillcolor=red]; + 128 [label="Access variable R|/node| [4]"]; + 129 [label="Access variable R|/token| [4]"]; + 130 [label="Delegated constructor call: super|>(...) [4]" style="filled" fillcolor=yellow]; + 131 [label="Exit function [4]" style="filled" fillcolor=red]; } subgraph cluster_48 { color=blue - 130 [label="Enter function [4]" style="filled" fillcolor=red]; - 131 [label="Access variable R|/node| [4]"]; - 132 [label="Access variable R|/token| [4]"]; - 133 [label="Delegated constructor call: super|>(...) [4]" style="filled" fillcolor=yellow]; - 134 [label="Exit function [4]" style="filled" fillcolor=red]; + 132 [label="Enter property [4]" style="filled" fillcolor=red]; + 133 [label="Access variable R|/tree| [4]"]; + 134 [label="Exit property [4]" style="filled" fillcolor=red]; } 135 [label="Exit class FirLightModifier [3]" style="filled" fillcolor=red]; } 126 -> {127} [color=green]; 126 -> {135} [style=dotted]; - 126 -> {127 130} [style=dashed]; + 126 -> {127 132} [style=dashed]; 127 -> {128}; 128 -> {129}; - 129 -> {130} [color=green]; + 129 -> {130}; 130 -> {131}; - 131 -> {132}; + 131 -> {132} [color=green]; 132 -> {133}; 133 -> {134}; 134 -> {135} [color=green]; @@ -459,31 +459,31 @@ digraph kt44814_kt { 136 [label="Enter class FirModifierList [2]" style="filled" fillcolor=red]; subgraph cluster_50 { color=blue - 137 [label="Enter property [3]" style="filled" fillcolor=red]; - subgraph cluster_51 { - color=blue - 138 [label="Function call arguments enter [3]"]; - 139 [label="Function call arguments exit [3]"]; - } - 140 [label="Function call: R|kotlin/collections/emptyList||>() [3]" style="filled" fillcolor=yellow]; - 141 [label="Exit property [3]" style="filled" fillcolor=red]; + 137 [label="Enter function [3]" style="filled" fillcolor=red]; + 138 [label="Delegated constructor call: super() [3]" style="filled" fillcolor=yellow]; + 139 [label="Exit function [3]" style="filled" fillcolor=red]; } - subgraph cluster_52 { + subgraph cluster_51 { color=blue - 142 [label="Enter function [3]" style="filled" fillcolor=red]; - 143 [label="Delegated constructor call: super() [3]" style="filled" fillcolor=yellow]; - 144 [label="Exit function [3]" style="filled" fillcolor=red]; + 140 [label="Enter property [3]" style="filled" fillcolor=red]; + subgraph cluster_52 { + color=blue + 141 [label="Function call arguments enter [3]"]; + 142 [label="Function call arguments exit [3]"]; + } + 143 [label="Function call: R|kotlin/collections/emptyList||>() [3]" style="filled" fillcolor=yellow]; + 144 [label="Exit property [3]" style="filled" fillcolor=red]; } 145 [label="Exit class FirModifierList [2]" style="filled" fillcolor=red]; } 136 -> {137} [color=green]; 136 -> {145} [style=dotted]; - 136 -> {137 142} [style=dashed]; + 136 -> {137 140} [style=dashed]; 137 -> {138}; 138 -> {139}; - 139 -> {140}; + 139 -> {140} [color=green]; 140 -> {141}; - 141 -> {142} [color=green]; + 141 -> {142}; 142 -> {143}; 143 -> {144}; 144 -> {145} [color=green]; @@ -493,15 +493,15 @@ digraph kt44814_kt { 146 [label="Enter class FirPsiModifierList [3]" style="filled" fillcolor=red]; subgraph cluster_54 { color=blue - 147 [label="Enter property [4]" style="filled" fillcolor=red]; - 148 [label="Access variable R|/modifierList| [4]"]; - 149 [label="Exit property [4]" style="filled" fillcolor=red]; + 147 [label="Enter function [4]" style="filled" fillcolor=red]; + 148 [label="Delegated constructor call: super() [4]" style="filled" fillcolor=yellow]; + 149 [label="Exit function [4]" style="filled" fillcolor=red]; } subgraph cluster_55 { color=blue - 150 [label="Enter function [4]" style="filled" fillcolor=red]; - 151 [label="Delegated constructor call: super() [4]" style="filled" fillcolor=yellow]; - 152 [label="Exit function [4]" style="filled" fillcolor=red]; + 150 [label="Enter property [4]" style="filled" fillcolor=red]; + 151 [label="Access variable R|/modifierList| [4]"]; + 152 [label="Exit property [4]" style="filled" fillcolor=red]; } 153 [label="Exit class FirPsiModifierList [3]" style="filled" fillcolor=red]; } @@ -520,21 +520,21 @@ digraph kt44814_kt { 154 [label="Enter class FirLightModifierList [3]" style="filled" fillcolor=red]; subgraph cluster_57 { color=blue - 155 [label="Enter property [4]" style="filled" fillcolor=red]; - 156 [label="Access variable R|/modifierList| [4]"]; - 157 [label="Exit property [4]" style="filled" fillcolor=red]; + 155 [label="Enter function [4]" style="filled" fillcolor=red]; + 156 [label="Delegated constructor call: super() [4]" style="filled" fillcolor=yellow]; + 157 [label="Exit function [4]" style="filled" fillcolor=red]; } subgraph cluster_58 { color=blue 158 [label="Enter property [4]" style="filled" fillcolor=red]; - 159 [label="Access variable R|/tree| [4]"]; + 159 [label="Access variable R|/modifierList| [4]"]; 160 [label="Exit property [4]" style="filled" fillcolor=red]; } subgraph cluster_59 { color=blue - 161 [label="Enter function [4]" style="filled" fillcolor=red]; - 162 [label="Delegated constructor call: super() [4]" style="filled" fillcolor=yellow]; - 163 [label="Exit function [4]" style="filled" fillcolor=red]; + 161 [label="Enter property [4]" style="filled" fillcolor=red]; + 162 [label="Access variable R|/tree| [4]"]; + 163 [label="Exit property [4]" style="filled" fillcolor=red]; } 164 [label="Exit class FirLightModifierList [3]" style="filled" fillcolor=red]; } diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/constructorPropertyInterdependence.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/constructorPropertyInterdependence.fir.kt index 89a0f558c6d..049a58e8dcb 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/constructorPropertyInterdependence.fir.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/constructorPropertyInterdependence.fir.kt @@ -3,6 +3,6 @@ open class A(val a: Any) { override fun toString() = a.toString() } -object B : A(B.foo) { // call B.foo should be not-allowed +object B : A(B.foo) { // call B.foo should be not-allowed val foo = 4 } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/deadCode/initializationInUnreachableCode.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/deadCode/initializationInUnreachableCode.fir.kt index 51c0ff29613..13ba7dc42cb 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/deadCode/initializationInUnreachableCode.fir.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/deadCode/initializationInUnreachableCode.fir.kt @@ -2,8 +2,8 @@ fun error(): Nothing = throw Exception() -class Some() { - var x: Int +class Some() { + var x: Int val y: Int = error() init { diff --git a/compiler/testData/diagnostics/tests/initializedAfterRethrow.fir.kt b/compiler/testData/diagnostics/tests/initializedAfterRethrow.fir.kt deleted file mode 100644 index 38c333276d4..00000000000 --- a/compiler/testData/diagnostics/tests/initializedAfterRethrow.fir.kt +++ /dev/null @@ -1,222 +0,0 @@ -fun foo(): Int = 42 - -object ThrowInTryWithCatch { - private val p: String - - init { - try { - throw Exception() - } catch (e: Exception) { - } - p = "OK" - } -} - -object ThrowInTryWithCatchAndFinally { - private val p: String - - init { - try { - throw Exception() - } catch (e: Exception) { - } finally { - } - p = "OK" - } -} - -object ThrowInFinally { - private val p: String - - init { - try { - foo() - } catch (e: Exception) { - } finally { - throw Exception() - } - p = "OK" - } -} - -object RethrowInCatch { - private val p: String - - init { - try { - foo() - } catch (e: Exception) { - throw e - } - p = "OK" - } -} - -object RethrowInCatchWithFinally { - private val p: String - - init { - try { - foo() - } catch (e: Exception) { - throw e - } finally { - } - p = "OK" - } -} - -object InnerTryWithCatch { - private val p: String - - init { - try { - foo() - } catch (e: Exception) { - try { - throw e - } catch (ee: Exception) { - } - } - p = "OK" - } -} - -object InnerTryWithFinally { - private val p: String - - init { - try { - foo() - } catch (e: Exception) { - try { - throw e - } finally { - } - } - p = "OK" - } -} - - -object InnerTryWithCatchAndFinally { - private val p: String - - init { - try { - foo() - } catch (e: Exception) { - try { - throw e - } catch (ee: Exception) { - } finally { - } - } - p = "OK" - } -} - -object InnerCatch { - private val p: String - - init { - try { - foo() - } catch (e: Exception) { - try { - foo() - } catch (ee: Exception) { - throw ee - } - } - p = "OK" - } -} - -object InnerCatchWithFinally { - private val p: String - - init { - try { - foo() - } catch (e: Exception) { - try { - foo() - } catch (ee: Exception) { - throw ee - } finally { - } - } - p = "OK" - } -} - -object InnerCatchOuterRethrow { - private val p: String - - init { - try { - foo() - } catch (e: Exception) { - try { - foo() - } catch (ee: Exception) { - throw e - } - } - p = "OK" - } -} - -object InnerCatchOuterRethrowWithFinally { - private val p: String - - init { - try { - foo() - } catch (e: Exception) { - try { - foo() - } catch (ee: Exception) { - throw e - } finally { - } - } - p = "OK" - } -} - -object InnerFinally { - private val p: String - - init { - try { - foo() - } catch (e: Exception) { - try { - foo() - } finally { - throw e - } - } - p = "OK" - } -} - -object InnerFinallyWithCatch { - private val p: String - - init { - try { - foo() - } catch (e: Exception) { - try { - foo() - } catch (ee: Exception) { - } finally { - throw e - } - } - p = "OK" - } -} diff --git a/compiler/testData/diagnostics/tests/initializedAfterRethrow.kt b/compiler/testData/diagnostics/tests/initializedAfterRethrow.kt index af394e1fa19..72dacac94a3 100644 --- a/compiler/testData/diagnostics/tests/initializedAfterRethrow.kt +++ b/compiler/testData/diagnostics/tests/initializedAfterRethrow.kt @@ -1,3 +1,5 @@ +// FIR_IDENTICAL + fun foo(): Int = 42 object ThrowInTryWithCatch { diff --git a/compiler/testData/diagnostics/tests/script/NestedInnerClass.dot b/compiler/testData/diagnostics/tests/script/NestedInnerClass.dot index 25cdc133efd..c96cb619aac 100644 --- a/compiler/testData/diagnostics/tests/script/NestedInnerClass.dot +++ b/compiler/testData/diagnostics/tests/script/NestedInnerClass.dot @@ -121,35 +121,35 @@ digraph NestedInnerClass_fir_kts { 35 [label="Enter class Inner [3]" style="filled" fillcolor=red]; subgraph cluster_13 { color=blue - 36 [label="Enter property [4]" style="filled" fillcolor=red]; - 37 [label="Access variable R|/property| [4]"]; - 38 [label="Exit property [4]" style="filled" fillcolor=red]; + 36 [label="Enter function [4]" style="filled" fillcolor=red]; + 37 [label="Delegated constructor call: super() [4]" style="filled" fillcolor=yellow]; + 38 [label="Exit function [4]" style="filled" fillcolor=red]; } subgraph cluster_14 { color=blue 39 [label="Enter property [4]" style="filled" fillcolor=red]; - 40 [label="Access variable this@NestedInnerClass# [4]"]; - 41 [label="Access variable # [4]"]; - 42 [label="Exit property [4]" style="filled" fillcolor=red]; + 40 [label="Access variable R|/property| [4]"]; + 41 [label="Exit property [4]" style="filled" fillcolor=red]; } subgraph cluster_15 { color=blue - 43 [label="Enter function [4]" style="filled" fillcolor=red]; - 44 [label="Delegated constructor call: super() [4]" style="filled" fillcolor=yellow]; - 45 [label="Exit function [4]" style="filled" fillcolor=red]; + 42 [label="Enter property [4]" style="filled" fillcolor=red]; + 43 [label="Access variable this@NestedInnerClass# [4]"]; + 44 [label="Access variable # [4]"]; + 45 [label="Exit property [4]" style="filled" fillcolor=red]; } 46 [label="Exit class Inner [3]" style="filled" fillcolor=red]; } 35 -> {36} [color=green]; 35 -> {46} [style=dotted]; - 35 -> {36 39 43} [style=dashed]; + 35 -> {36 39 42} [style=dashed]; 36 -> {37}; 37 -> {38}; 38 -> {39} [color=green]; 39 -> {40}; 40 -> {41}; - 41 -> {42}; - 42 -> {43} [color=green]; + 41 -> {42} [color=green]; + 42 -> {43}; 43 -> {44}; 44 -> {45}; 45 -> {46} [color=green]; diff --git a/compiler/testData/diagnostics/tests/script/NestedInnerClass.ll.dot b/compiler/testData/diagnostics/tests/script/NestedInnerClass.ll.dot index 624344a6015..40872a735f7 100644 --- a/compiler/testData/diagnostics/tests/script/NestedInnerClass.ll.dot +++ b/compiler/testData/diagnostics/tests/script/NestedInnerClass.ll.dot @@ -121,35 +121,35 @@ digraph NestedInnerClass_ll_kts { 35 [label="Enter class Inner [3]" style="filled" fillcolor=red]; subgraph cluster_13 { color=blue - 36 [label="Enter property [4]" style="filled" fillcolor=red]; - 37 [label="Access variable R|/property| [4]"]; - 38 [label="Exit property [4]" style="filled" fillcolor=red]; + 36 [label="Enter function [4]" style="filled" fillcolor=red]; + 37 [label="Delegated constructor call: super() [4]" style="filled" fillcolor=yellow]; + 38 [label="Exit function [4]" style="filled" fillcolor=red]; } subgraph cluster_14 { color=blue 39 [label="Enter property [4]" style="filled" fillcolor=red]; - 40 [label="Access variable this@NestedInnerClass# [4]"]; - 41 [label="Access variable # [4]"]; - 42 [label="Exit property [4]" style="filled" fillcolor=red]; + 40 [label="Access variable R|/property| [4]"]; + 41 [label="Exit property [4]" style="filled" fillcolor=red]; } subgraph cluster_15 { color=blue - 43 [label="Enter function [4]" style="filled" fillcolor=red]; - 44 [label="Delegated constructor call: super() [4]" style="filled" fillcolor=yellow]; - 45 [label="Exit function [4]" style="filled" fillcolor=red]; + 42 [label="Enter property [4]" style="filled" fillcolor=red]; + 43 [label="Access variable this@NestedInnerClass# [4]"]; + 44 [label="Access variable # [4]"]; + 45 [label="Exit property [4]" style="filled" fillcolor=red]; } 46 [label="Exit class Inner [3]" style="filled" fillcolor=red]; } 35 -> {36} [color=green]; 35 -> {46} [style=dotted]; - 35 -> {36 39 43} [style=dashed]; + 35 -> {36 39 42} [style=dashed]; 36 -> {37}; 37 -> {38}; 38 -> {39} [color=green]; 39 -> {40}; 40 -> {41}; - 41 -> {42}; - 42 -> {43} [color=green]; + 41 -> {42} [color=green]; + 42 -> {43}; 43 -> {44}; 44 -> {45}; 45 -> {46} [color=green];