From b71e4ebb3fb661041d35621b42befa461c26fed4 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 12 Feb 2020 15:54:47 +0300 Subject: [PATCH] [FIR-TEST] Add `!DUMP_CFG` directive. Get rid of cfg diagnostic tests --- .../testData/resolve/cfg/binaryOperations.kt | 1 + .../resolve/cfg/booleanOperatorsWithConsts.kt | 1 + .../resolve/testData/resolve/cfg/complex.dot | 585 +++++++----------- .../resolve/testData/resolve/cfg/complex.kt | 20 +- .../resolve/testData/resolve/cfg/complex.txt | 26 +- .../resolve/testData/resolve/cfg/emptyWhen.kt | 1 + .../resolve/testData/resolve/cfg/initBlock.kt | 1 + .../resolve/cfg/initBlockAndInPlaceLambda.kt | 1 + .../resolve/testData/resolve/cfg/jumps.dot | 6 +- .../fir/resolve/testData/resolve/cfg/jumps.kt | 5 +- .../resolve/testData/resolve/cfg/jumps.txt | 4 +- .../resolve/testData/resolve/cfg/jumps_0.dot | 363 ----------- .../resolve/testData/resolve/cfg/jumps_1.dot | 358 ----------- .../resolve/testData/resolve/cfg/lambdas.kt | 1 + .../fir/resolve/testData/resolve/cfg/loops.kt | 1 + .../testData/resolve/cfg/postponedLambdas.kt | 1 + .../resolve/cfg/propertiesAndInitBlocks.kt | 1 + .../resolve/cfg/returnValuesFromLambda.kt | 1 + .../resolve/testData/resolve/cfg/safeCalls.kt | 1 + .../resolve/testData/resolve/cfg/simple.kt | 1 + .../resolve/testData/resolve/cfg/tryCatch.kt | 1 + .../fir/resolve/testData/resolve/cfg/when.kt | 1 + .../testData/resolve/smartcasts/bangbang.kt | 1 + .../smartcasts/booleans/booleanOperators.kt | 1 + .../smartcasts/booleans/equalsToBoolean.kt | 1 + .../boundSmartcasts/boundSmartcasts.dot | 2 +- .../boundSmartcasts/boundSmartcasts.kt | 3 +- .../boundSmartcasts/boundSmartcasts.txt | 2 +- .../boundSmartcastsInBranches.kt | 1 + .../testData/resolve/smartcasts/casts.kt | 1 + .../smartcasts/controlStructures/elvis.kt | 1 + .../smartcasts/controlStructures/returns.dot | 6 +- .../smartcasts/controlStructures/returns.kt | 3 +- .../smartcasts/controlStructures/returns.txt | 4 +- .../smartcasts/controlStructures/simpleIf.kt | 1 + .../smartcastFromArgument.kt | 1 + .../smartcasts/controlStructures/when.kt | 1 + .../resolve/smartcasts/equalsAndIdentity.kt | 1 + .../smartcasts/lambdas/inPlaceLambdas.kt | 1 + .../smartcasts/lambdas/smartcastOnLambda.kt | 1 + .../loops/dataFlowInfoFromWhileCondition.kt | 1 + .../resolve/smartcasts/loops/endlessLoops.kt | 1 + .../resolve/smartcasts/multipleCasts.kt | 1 + .../resolve/smartcasts/nullability.dot | 36 +- .../resolve/smartcasts/nullability.kt | 37 +- .../resolve/smartcasts/nullability.txt | 36 +- .../problems/smartcastOnBangBang.kt | 1 + .../implicitReceiverAsWhenSubject.kt | 1 + .../smartcasts/receivers/implicitReceivers.kt | 1 + .../receivers/thisOfExtensionProperty.kt | 2 +- .../smartcasts/safeCalls/assignSafeCall.kt | 1 + .../safeCalls/safeCallAndEqualityToBool.dot | 431 ++++++------- .../safeCalls/safeCallAndEqualityToBool.kt | 11 +- .../safeCalls/safeCallAndEqualityToBool.txt | 11 +- .../resolve/smartcasts/safeCalls/safeCalls.kt | 1 + .../resolve/smartcasts/smartCastInInit.kt | 1 + .../resolve/smartcasts/smartcastToNothing.kt | 1 + .../smartcasts/stability/overridenOpenVal.kt | 1 + .../smartcasts/variables/delayedAssignment.kt | 1 + .../variables/smartcastAfterReassignment.kt | 1 + .../contracts/callsInPlace.kt | 1 + .../contracts/conditionalEffects.kt | 1 + .../smartcasts/tryWithLambdaInside.kt | 1 + .../AbstractFirCfgBuildingWithStdlibTest.kt | 14 - .../kotlin/fir/AbstractFirDiagnosticTest.kt | 101 +++ .../fir/AbstractFirDiagnosticsWithCfgTest.kt | 98 --- .../fir/FirDiagnosticsTestGenerated.java | 388 +++++++++++- ...gnosticsWithCfgAndStdlibTestGenerated.java | 61 -- .../FirDiagnosticsWithCfgTestGenerated.java | 406 ------------ ...DiagnosticsWithLightTreeTestGenerated.java | 388 +++++++++++- ...FirDiagnosticsWithStdlibTestGenerated.java | 43 +- .../generators/tests/GenerateCompilerTests.kt | 16 +- 72 files changed, 1501 insertions(+), 2007 deletions(-) delete mode 100644 compiler/fir/resolve/testData/resolve/cfg/jumps_0.dot delete mode 100644 compiler/fir/resolve/testData/resolve/cfg/jumps_1.dot delete mode 100644 compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/AbstractFirCfgBuildingWithStdlibTest.kt delete mode 100644 compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/AbstractFirDiagnosticsWithCfgTest.kt delete mode 100644 compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithCfgAndStdlibTestGenerated.java delete mode 100644 compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithCfgTestGenerated.java diff --git a/compiler/fir/resolve/testData/resolve/cfg/binaryOperations.kt b/compiler/fir/resolve/testData/resolve/cfg/binaryOperations.kt index 60a3c7599f5..a40f5701438 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/binaryOperations.kt +++ b/compiler/fir/resolve/testData/resolve/cfg/binaryOperations.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG fun test_1(b1: Boolean, b2: Boolean) { if (b1 || b2) { 1 diff --git a/compiler/fir/resolve/testData/resolve/cfg/booleanOperatorsWithConsts.kt b/compiler/fir/resolve/testData/resolve/cfg/booleanOperatorsWithConsts.kt index 97ee5188bfc..7d264eb9f7a 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/booleanOperatorsWithConsts.kt +++ b/compiler/fir/resolve/testData/resolve/cfg/booleanOperatorsWithConsts.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG fun test_1(b: Boolean) { if (b || false) { 1 diff --git a/compiler/fir/resolve/testData/resolve/cfg/complex.dot b/compiler/fir/resolve/testData/resolve/cfg/complex.dot index edc72546f1b..42c351749f6 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/complex.dot +++ b/compiler/fir/resolve/testData/resolve/cfg/complex.dot @@ -5,252 +5,101 @@ digraph complex_kt { subgraph cluster_0 { color=red - 0 [label="Enter function fetchPluginReleaseDate" style="filled" fillcolor=red]; - 1 [label="Const: String(https://plugins.jetbrains.com/api/plugins/)"]; - 2 [label="Access variable R|/pluginId|"]; - 3 [label="Access variable #"]; - 4 [label="Function call: R|/pluginId|.#.R|kotlin/toString|()"]; - 5 [label="Const: String(/updates?version=)"]; - 6 [label="Access variable R|/version|"]; - 7 [label="Function call: R|/version|.R|kotlin/Any.toString|()"]; - 8 [label="Variable declaration: lval url: R|kotlin/String|"]; - subgraph cluster_1 { - color=blue - 9 [label="Try expression enter"]; - subgraph cluster_2 { - color=blue - 10 [label="Try main block enter"]; - subgraph cluster_3 { - color=blue - 11 [label="Enter block"]; - 12 [label="Access variable #"]; - 13 [label="Access variable R|/url|"]; - 14 [label="Access variable R|/url|"]; - 15 [label="Access variable R|/url|"]; - 16 [label="Function call: #.#(R|/url|)"]; - 17 [label="Postponed enter to lambda"]; - 18 [label="Postponed exit from lambda"]; - 19 [label="Function call: #.#(R|/url|).#( = connect@fun (): R|ERROR CLASS: Unresolved name: fromJson| { - ^ #().#().#(#.#.#(), (Q|kotlin/Array|).R|kotlin/jvm/java|) -} -)"]; - 20 [label="Exit block"]; - } - 21 [label="Try main block exit"]; - } - subgraph cluster_4 { - color=blue - 22 [label="Catch enter"]; - subgraph cluster_5 { - color=blue - 23 [label="Enter block"]; - 24 [label="Const: String(Can't parse json response)"]; - 25 [label="Access variable R|/syntaxException|"]; - 26 [label="Access variable R|/syntaxException|"]; - 27 [label="Access variable R|/syntaxException|"]; - 28 [label="Function call: #(String(Can't parse json response), R|/syntaxException|)"]; - 29 [label="Throw: throw #(String(Can't parse json response), R|/syntaxException|)"]; - 30 [label="Stub" style="filled" fillcolor=gray]; - 31 [label="Exit block" style="filled" fillcolor=gray]; - } - 32 [label="Catch exit" style="filled" fillcolor=gray]; - } - subgraph cluster_6 { - color=blue - 33 [label="Catch enter"]; - subgraph cluster_7 { - color=blue - 34 [label="Enter block"]; - 35 [label="Access variable R|/ioException|"]; - 36 [label="Access variable R|/ioException|"]; - 37 [label="Access variable R|/ioException|"]; - 38 [label="Function call: #(R|/ioException|)"]; - 39 [label="Throw: throw #(R|/ioException|)"]; - 40 [label="Stub" style="filled" fillcolor=gray]; - 41 [label="Exit block" style="filled" fillcolor=gray]; - } - 42 [label="Catch exit" style="filled" fillcolor=gray]; - } - 43 [label="Try expression exit"]; - } - 44 [label="Variable declaration: lval pluginDTOs: R|kotlin/Array|"]; - 45 [label="Exit function fetchPluginReleaseDate" style="filled" fillcolor=red]; - } - subgraph cluster_8 { - color=blue - 46 [label="Enter annotation"]; - 47 [label="Access variable #"]; - 48 [label="Access variable #"]; - 49 [label="Exit annotation"]; + 0 [label="Enter function close" style="filled" fillcolor=red]; + 1 [label="Exit function close" style="filled" fillcolor=red]; } 0 -> {1}; - 1 -> {2}; + + subgraph cluster_1 { + color=red + 2 [label="Enter function addSuppressed" style="filled" fillcolor=red]; + 3 [label="Exit function addSuppressed" style="filled" fillcolor=red]; + } + 2 -> {3}; - 3 -> {4}; - 4 -> {5}; - 5 -> {6}; - 6 -> {7}; - 7 -> {8}; - 8 -> {9}; - 9 -> {10}; - 10 -> {45 33 22 11}; - 11 -> {12}; - 12 -> {13}; - 13 -> {14}; - 14 -> {15}; - 15 -> {16}; - 16 -> {17}; - 17 -> {18 18} [color=green]; - 18 -> {19}; - 19 -> {20}; - 20 -> {21}; - 21 -> {43}; - 22 -> {45 23}; - 23 -> {24}; - 24 -> {25}; - 25 -> {26}; - 26 -> {27}; - 27 -> {28}; - 28 -> {29}; - 29 -> {45}; - 29 -> {30} [style=dotted]; - 30 -> {31} [style=dotted]; - 31 -> {32} [style=dotted]; - 32 -> {43} [style=dotted]; - 33 -> {45 34}; - 34 -> {35}; - 35 -> {36}; - 36 -> {37}; - 37 -> {38}; - 38 -> {39}; - 39 -> {45}; - 39 -> {40} [style=dotted]; - 40 -> {41} [style=dotted]; - 41 -> {42} [style=dotted]; - 42 -> {43} [style=dotted]; - 43 -> {44}; - 44 -> {45}; - 45 -> {46}; - 46 -> {47}; - 47 -> {48}; - 48 -> {49}; - subgraph cluster_9 { + subgraph cluster_2 { color=red - 50 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; - 51 [label="Function call: #()"]; - 52 [label="Function call: #().#()"]; - 53 [label="Access variable #"]; - 54 [label="Access variable #"]; - 55 [label="Function call: #.#.#()"]; - 56 [label="Access variable R|kotlin/jvm/java|"]; - 57 [label="Access variable R|kotlin/jvm/java|"]; - 58 [label="Access variable R|kotlin/jvm/java|"]; - 59 [label="Function call: #().#().#(#.#.#(), (Q|kotlin/Array|).R|kotlin/jvm/java|)"]; - 60 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; - } - - 50 -> {51}; - 51 -> {52}; - 52 -> {53}; - 53 -> {54}; - 54 -> {55}; - 55 -> {56}; - 56 -> {57}; - 57 -> {58}; - 58 -> {59}; - 59 -> {60}; - - subgraph cluster_10 { - color=red - 61 [label="Enter function close" style="filled" fillcolor=red]; - 62 [label="Exit function close" style="filled" fillcolor=red]; - } - - 61 -> {62}; - - subgraph cluster_11 { - color=red - 63 [label="Enter function closeFinally" style="filled" fillcolor=red]; - subgraph cluster_12 { + 4 [label="Enter function closeFinally" style="filled" fillcolor=red]; + subgraph cluster_3 { color=blue - 64 [label="Enter when"]; + 5 [label="Enter when"]; + subgraph cluster_4 { + color=blue + 6 [label="Enter when branch condition "]; + 7 [label="Access variable this@R|/closeFinally|"]; + 8 [label="Const: Null(null)"]; + 9 [label="Operator =="]; + 10 [label="Exit when branch condition"]; + } + subgraph cluster_5 { + color=blue + 11 [label="Enter when branch condition "]; + 12 [label="Access variable R|/cause|"]; + 13 [label="Const: Null(null)"]; + 14 [label="Operator =="]; + 15 [label="Exit when branch condition"]; + } + subgraph cluster_6 { + color=blue + 16 [label="Enter when branch condition else"]; + 17 [label="Exit when branch condition"]; + } + 18 [label="Enter when branch result"]; + subgraph cluster_7 { + color=blue + 19 [label="Enter block"]; + subgraph cluster_8 { + color=blue + 20 [label="Try expression enter"]; + subgraph cluster_9 { + color=blue + 21 [label="Try main block enter"]; + subgraph cluster_10 { + color=blue + 22 [label="Enter block"]; + 23 [label="Function call: this@R|/closeFinally|.R|/AutoCloseable.close|()"]; + 24 [label="Exit block"]; + } + 25 [label="Try main block exit"]; + } + subgraph cluster_11 { + color=blue + 26 [label="Catch enter"]; + subgraph cluster_12 { + color=blue + 27 [label="Enter block"]; + 28 [label="Access variable R|/cause|"]; + 29 [label="Access variable R|/closeException|"]; + 30 [label="Function call: R|/cause|.R|/addSuppressed|(R|/closeException|)"]; + 31 [label="Exit block"]; + } + 32 [label="Catch exit"]; + } + 33 [label="Try expression exit"]; + } + 34 [label="Exit block"]; + } + 35 [label="Exit when branch result"]; + 36 [label="Enter when branch result"]; subgraph cluster_13 { color=blue - 65 [label="Enter when branch condition "]; - 66 [label="Access variable this@R|/closeFinally|"]; - 67 [label="Const: Null(null)"]; - 68 [label="Operator =="]; - 69 [label="Exit when branch condition"]; + 37 [label="Enter block"]; + 38 [label="Function call: this@R|/closeFinally|.R|/AutoCloseable.close|()"]; + 39 [label="Exit block"]; } + 40 [label="Exit when branch result"]; + 41 [label="Enter when branch result"]; subgraph cluster_14 { color=blue - 70 [label="Enter when branch condition "]; - 71 [label="Access variable R|/cause|"]; - 72 [label="Const: Null(null)"]; - 73 [label="Operator =="]; - 74 [label="Exit when branch condition"]; + 42 [label="Enter block"]; + 43 [label="Exit block"]; } - subgraph cluster_15 { - color=blue - 75 [label="Enter when branch condition else"]; - 76 [label="Exit when branch condition"]; - } - 77 [label="Enter when branch result"]; - subgraph cluster_16 { - color=blue - 78 [label="Enter block"]; - subgraph cluster_17 { - color=blue - 79 [label="Try expression enter"]; - subgraph cluster_18 { - color=blue - 80 [label="Try main block enter"]; - subgraph cluster_19 { - color=blue - 81 [label="Enter block"]; - 82 [label="Function call: this@R|/closeFinally|.R|/AutoCloseable.close|()"]; - 83 [label="Exit block"]; - } - 84 [label="Try main block exit"]; - } - subgraph cluster_20 { - color=blue - 85 [label="Catch enter"]; - subgraph cluster_21 { - color=blue - 86 [label="Enter block"]; - 87 [label="Access variable R|/cause|"]; - 88 [label="Access variable R|/closeException|"]; - 89 [label="Function call: R|/cause|.R|kotlin/addSuppressed|(R|/closeException|)"]; - 90 [label="Exit block"]; - } - 91 [label="Catch exit"]; - } - 92 [label="Try expression exit"]; - } - 93 [label="Exit block"]; - } - 94 [label="Exit when branch result"]; - 95 [label="Enter when branch result"]; - subgraph cluster_22 { - color=blue - 96 [label="Enter block"]; - 97 [label="Function call: this@R|/closeFinally|.R|/AutoCloseable.close|()"]; - 98 [label="Exit block"]; - } - 99 [label="Exit when branch result"]; - 100 [label="Enter when branch result"]; - subgraph cluster_23 { - color=blue - 101 [label="Enter block"]; - 102 [label="Exit block"]; - } - 103 [label="Exit when branch result"]; - 104 [label="Exit when"]; + 44 [label="Exit when branch result"]; + 45 [label="Exit when"]; } - 105 [label="Jump: ^closeFinally when () { + 46 [label="Jump: ^closeFinally when () { ==(this@R|/closeFinally|, Null(null)) -> { } ==(R|/cause|, Null(null)) -> { @@ -261,161 +110,161 @@ digraph complex_kt { this@R|/closeFinally|.R|/AutoCloseable.close|() } catch (closeException: R|kotlin/Throwable|) { - R|/cause|.R|kotlin/addSuppressed|(R|/closeException|) + R|/cause|.R|/addSuppressed|(R|/closeException|) } } } "]; - 106 [label="Stub" style="filled" fillcolor=gray]; - 107 [label="Exit function closeFinally" style="filled" fillcolor=red]; + 47 [label="Stub" style="filled" fillcolor=gray]; + 48 [label="Exit function closeFinally" style="filled" fillcolor=red]; } + 4 -> {5}; + 5 -> {6}; + 6 -> {7}; + 7 -> {8}; + 8 -> {9}; + 9 -> {10}; + 10 -> {41 11}; + 11 -> {12}; + 12 -> {13}; + 13 -> {14}; + 14 -> {15}; + 15 -> {36 16}; + 16 -> {17}; + 17 -> {18}; + 18 -> {19}; + 19 -> {20}; + 20 -> {21}; + 21 -> {48 26 22}; + 22 -> {23}; + 23 -> {24}; + 24 -> {25}; + 25 -> {33}; + 26 -> {48 27}; + 27 -> {28}; + 28 -> {29}; + 29 -> {30}; + 30 -> {31}; + 31 -> {32}; + 32 -> {33}; + 33 -> {34}; + 34 -> {35}; + 35 -> {45}; + 36 -> {37}; + 37 -> {38}; + 38 -> {39}; + 39 -> {40}; + 40 -> {45}; + 41 -> {42}; + 42 -> {43}; + 43 -> {44}; + 44 -> {45}; + 45 -> {46}; + 46 -> {48}; + 46 -> {47} [style=dotted]; + 47 -> {48} [style=dotted]; + + subgraph cluster_15 { + color=red + 49 [label="Enter function firstIsInstanceOrNull" style="filled" fillcolor=red]; + 50 [label="Access variable this@R|/firstIsInstanceOrNull|"]; + 51 [label="Variable declaration: lval : R|kotlin/collections/List<*>|"]; + 52 [label="Access variable R|/|"]; + 53 [label="Function call: R|/|.R|FakeOverride|>|()"]; + 54 [label="Variable declaration: lval : R|kotlin/collections/Iterator|"]; + subgraph cluster_16 { + color=blue + 55 [label="Enter while loop"]; + subgraph cluster_17 { + color=blue + 56 [label="Enter loop condition"]; + 57 [label="Access variable R|/|"]; + 58 [label="Function call: R|/|.R|kotlin/collections/Iterator.hasNext|()"]; + 59 [label="Exit loop condition"]; + } + subgraph cluster_18 { + color=blue + 60 [label="Enter loop block"]; + subgraph cluster_19 { + color=blue + 61 [label="Enter block"]; + 62 [label="Access variable R|/|"]; + 63 [label="Function call: R|/|.R|FakeOverride|()"]; + 64 [label="Variable declaration: lval element: R|kotlin/Any?|"]; + subgraph cluster_20 { + color=blue + 65 [label="Enter when"]; + subgraph cluster_21 { + color=blue + 66 [label="Enter when branch condition "]; + 67 [label="Access variable R|/element|"]; + 68 [label="Type operator: element is T"]; + 69 [label="Exit when branch condition"]; + } + 70 [label="Synthetic else branch"]; + 71 [label="Enter when branch result"]; + subgraph cluster_22 { + color=blue + 72 [label="Enter block"]; + 73 [label="Access variable R|/element|"]; + 74 [label="Jump: ^firstIsInstanceOrNull R|/element|"]; + 75 [label="Stub" style="filled" fillcolor=gray]; + 76 [label="Exit block" style="filled" fillcolor=gray]; + } + 77 [label="Exit when branch result" style="filled" fillcolor=gray]; + 78 [label="Exit when"]; + } + 79 [label="Exit block"]; + } + 80 [label="Exit loop block"]; + } + 81 [label="Exit whileloop"]; + } + 82 [label="Const: Null(null)"]; + 83 [label="Jump: ^firstIsInstanceOrNull Null(null)"]; + 84 [label="Stub" style="filled" fillcolor=gray]; + 85 [label="Exit function firstIsInstanceOrNull" style="filled" fillcolor=red]; + } + + 49 -> {50}; + 50 -> {51}; + 51 -> {52}; + 52 -> {53}; + 53 -> {54}; + 54 -> {55}; + 55 -> {56}; + 56 -> {57}; + 57 -> {58}; + 58 -> {59}; + 59 -> {81 60}; + 60 -> {61}; + 61 -> {62}; + 62 -> {63}; 63 -> {64}; 64 -> {65}; 65 -> {66}; 66 -> {67}; 67 -> {68}; 68 -> {69}; - 69 -> {100 70}; - 70 -> {71}; + 69 -> {71 70}; + 70 -> {78}; 71 -> {72}; 72 -> {73}; 73 -> {74}; - 74 -> {95 75}; - 75 -> {76}; - 76 -> {77}; - 77 -> {78}; + 74 -> {85}; + 74 -> {75} [style=dotted]; + 75 -> {76} [style=dotted]; + 76 -> {77} [style=dotted]; + 77 -> {78} [style=dotted]; 78 -> {79}; 79 -> {80}; - 80 -> {107 85 81}; + 80 -> {56}; 81 -> {82}; 82 -> {83}; - 83 -> {84}; - 84 -> {92}; - 85 -> {107 86}; - 86 -> {87}; - 87 -> {88}; - 88 -> {89}; - 89 -> {90}; - 90 -> {91}; - 91 -> {92}; - 92 -> {93}; - 93 -> {94}; - 94 -> {104}; - 95 -> {96}; - 96 -> {97}; - 97 -> {98}; - 98 -> {99}; - 99 -> {104}; - 100 -> {101}; - 101 -> {102}; - 102 -> {103}; - 103 -> {104}; - 104 -> {105}; - 105 -> {107}; - 105 -> {106} [style=dotted]; - 106 -> {107} [style=dotted]; - - subgraph cluster_24 { - color=red - 108 [label="Enter function firstIsInstanceOrNull" style="filled" fillcolor=red]; - 109 [label="Access variable this@R|/firstIsInstanceOrNull|"]; - 110 [label="Variable declaration: lval : R|kotlin/sequences/Sequence<*>|"]; - 111 [label="Access variable R|/|"]; - 112 [label="Function call: R|/|.R|FakeOverride|>|()"]; - 113 [label="Variable declaration: lval : R|kotlin/collections/Iterator|"]; - subgraph cluster_25 { - color=blue - 114 [label="Enter while loop"]; - subgraph cluster_26 { - color=blue - 115 [label="Enter loop condition"]; - 116 [label="Access variable R|/|"]; - 117 [label="Function call: R|/|.R|kotlin/collections/Iterator.hasNext|()"]; - 118 [label="Exit loop condition"]; - } - subgraph cluster_27 { - color=blue - 119 [label="Enter loop block"]; - subgraph cluster_28 { - color=blue - 120 [label="Enter block"]; - 121 [label="Access variable R|/|"]; - 122 [label="Function call: R|/|.R|FakeOverride|()"]; - 123 [label="Variable declaration: lval element: R|kotlin/Any?|"]; - subgraph cluster_29 { - color=blue - 124 [label="Enter when"]; - subgraph cluster_30 { - color=blue - 125 [label="Enter when branch condition "]; - 126 [label="Access variable R|/element|"]; - 127 [label="Type operator: element is T"]; - 128 [label="Exit when branch condition"]; - } - 129 [label="Synthetic else branch"]; - 130 [label="Enter when branch result"]; - subgraph cluster_31 { - color=blue - 131 [label="Enter block"]; - 132 [label="Access variable R|/element|"]; - 133 [label="Jump: ^firstIsInstanceOrNull R|/element|"]; - 134 [label="Stub" style="filled" fillcolor=gray]; - 135 [label="Exit block" style="filled" fillcolor=gray]; - } - 136 [label="Exit when branch result" style="filled" fillcolor=gray]; - 137 [label="Exit when"]; - } - 138 [label="Exit block"]; - } - 139 [label="Exit loop block"]; - } - 140 [label="Exit whileloop"]; - } - 141 [label="Const: Null(null)"]; - 142 [label="Jump: ^firstIsInstanceOrNull Null(null)"]; - 143 [label="Stub" style="filled" fillcolor=gray]; - 144 [label="Exit function firstIsInstanceOrNull" style="filled" fillcolor=red]; - } - - 108 -> {109}; - 109 -> {110}; - 110 -> {111}; - 111 -> {112}; - 112 -> {113}; - 113 -> {114}; - 114 -> {115}; - 115 -> {116}; - 116 -> {117}; - 117 -> {118}; - 118 -> {140 119}; - 119 -> {120}; - 120 -> {121}; - 121 -> {122}; - 122 -> {123}; - 123 -> {124}; - 124 -> {125}; - 125 -> {126}; - 126 -> {127}; - 127 -> {128}; - 128 -> {130 129}; - 129 -> {137}; - 130 -> {131}; - 131 -> {132}; - 132 -> {133}; - 133 -> {144}; - 133 -> {134} [style=dotted]; - 134 -> {135} [style=dotted]; - 135 -> {136} [style=dotted]; - 136 -> {137} [style=dotted]; - 137 -> {138}; - 138 -> {139}; - 139 -> {115}; - 140 -> {141}; - 141 -> {142}; - 142 -> {144}; - 142 -> {143} [style=dotted]; - 143 -> {144} [style=dotted]; + 83 -> {85}; + 83 -> {84} [style=dotted]; + 84 -> {85} [style=dotted]; } diff --git a/compiler/fir/resolve/testData/resolve/cfg/complex.kt b/compiler/fir/resolve/testData/resolve/cfg/complex.kt index 405889df126..3da982bef9a 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/complex.kt +++ b/compiler/fir/resolve/testData/resolve/cfg/complex.kt @@ -1,22 +1,10 @@ -@Throws(IOException::class, ResponseParseException::class) -fun fetchPluginReleaseDate(pluginId: PluginId, version: String, channel: String?): LocalDate? { - val url = "https://plugins.jetbrains.com/api/plugins/${pluginId.idString}/updates?version=$version" - - val pluginDTOs: Array = try { - HttpRequests.request(url).connect { - GsonBuilder().create().fromJson(it.inputStream.reader(), Array::class.java) - } - } catch (ioException: JsonIOException) { - throw IOException(ioException) - } catch (syntaxException: JsonSyntaxException) { - throw ResponseParseException("Can't parse json response", syntaxException) - } -} - +// !DUMP_CFG interface AutoCloseable { fun close() } +fun Throwable.addSuppressed(other: Throwable) {} + internal fun AutoCloseable?.closeFinally(cause: Throwable?) = when { this == null -> {} cause == null -> close() @@ -28,7 +16,7 @@ internal fun AutoCloseable?.closeFinally(cause: Throwable?) = when { } } -inline fun Sequence<*>.firstIsInstanceOrNull(): T? { +inline fun List<*>.firstIsInstanceOrNull(): T? { for (element in this) if (element is T) return element return null } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/cfg/complex.txt b/compiler/fir/resolve/testData/resolve/cfg/complex.txt index 696d744c418..ad2a6c2339a 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/complex.txt +++ b/compiler/fir/resolve/testData/resolve/cfg/complex.txt @@ -1,23 +1,9 @@ FILE: complex.kt - @R|kotlin/jvm/Throws|((#), (#)) public final fun fetchPluginReleaseDate(pluginId: R|ERROR CLASS: Symbol not found, for `PluginId`|, version: R|kotlin/String|, channel: R|kotlin/String?|): R|ERROR CLASS: Symbol not found, for `LocalDate?`| { - lval url: R|kotlin/String| = (String(https://plugins.jetbrains.com/api/plugins/), R|/pluginId|.#.R|kotlin/toString|(), String(/updates?version=), R|/version|.R|kotlin/Any.toString|()) - lval pluginDTOs: R|kotlin/Array| = try { - #.#(R|/url|).#( = connect@fun (): R|ERROR CLASS: Unresolved name: fromJson| { - ^ #().#().#(#.#.#(), (Q|kotlin/Array|).R|kotlin/jvm/java|) - } - ) - } - catch (ioException: R|ERROR CLASS: Symbol not found, for `JsonIOException`|) { - throw #(R|/ioException|) - } - catch (syntaxException: R|ERROR CLASS: Symbol not found, for `JsonSyntaxException`|) { - throw #(String(Can't parse json response), R|/syntaxException|) - } - - } public abstract interface AutoCloseable : R|kotlin/Any| { public abstract fun close(): R|kotlin/Unit| + } + public final fun R|kotlin/Throwable|.addSuppressed(other: R|kotlin/Throwable|): R|kotlin/Unit| { } internal final fun R|AutoCloseable?|.closeFinally(cause: R|kotlin/Throwable?|): R|kotlin/Unit| { ^closeFinally when () { @@ -31,16 +17,16 @@ FILE: complex.kt this@R|/closeFinally|.R|/AutoCloseable.close|() } catch (closeException: R|kotlin/Throwable|) { - R|/cause|.R|kotlin/addSuppressed|(R|/closeException|) + R|/cause|.R|/addSuppressed|(R|/closeException|) } } } } - public final inline fun R|kotlin/sequences/Sequence<*>|.firstIsInstanceOrNull(): R|T?| { - lval : R|kotlin/sequences/Sequence<*>| = this@R|/firstIsInstanceOrNull| - lval : R|kotlin/collections/Iterator| = R|/|.R|FakeOverride|>|() + public final inline fun R|kotlin/collections/List<*>|.firstIsInstanceOrNull(): R|T?| { + lval : R|kotlin/collections/List<*>| = this@R|/firstIsInstanceOrNull| + lval : R|kotlin/collections/Iterator| = R|/|.R|FakeOverride|>|() while(R|/|.R|kotlin/collections/Iterator.hasNext|()) { lval element: R|kotlin/Any?| = R|/|.R|FakeOverride|() when () { diff --git a/compiler/fir/resolve/testData/resolve/cfg/emptyWhen.kt b/compiler/fir/resolve/testData/resolve/cfg/emptyWhen.kt index 614132c536a..31a170b91f0 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/emptyWhen.kt +++ b/compiler/fir/resolve/testData/resolve/cfg/emptyWhen.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG fun test_1() { when {} } diff --git a/compiler/fir/resolve/testData/resolve/cfg/initBlock.kt b/compiler/fir/resolve/testData/resolve/cfg/initBlock.kt index 1c4c7748d0b..9b01e0cfee0 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/initBlock.kt +++ b/compiler/fir/resolve/testData/resolve/cfg/initBlock.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG class Foo { init { val x = 1 diff --git a/compiler/fir/resolve/testData/resolve/cfg/initBlockAndInPlaceLambda.kt b/compiler/fir/resolve/testData/resolve/cfg/initBlockAndInPlaceLambda.kt index 205094570ee..9ee834e3e1c 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/initBlockAndInPlaceLambda.kt +++ b/compiler/fir/resolve/testData/resolve/cfg/initBlockAndInPlaceLambda.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG interface B interface A { diff --git a/compiler/fir/resolve/testData/resolve/cfg/jumps.dot b/compiler/fir/resolve/testData/resolve/cfg/jumps.dot index 6e3b6791d22..99d640b7fff 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/jumps.dot +++ b/compiler/fir/resolve/testData/resolve/cfg/jumps.dot @@ -34,8 +34,8 @@ digraph jumps_kt { subgraph cluster_5 { color=blue 15 [label="Enter block"]; - 16 [label="Function call: R|kotlin/KotlinNullPointerException.KotlinNullPointerException|()"]; - 17 [label="Throw: throw R|kotlin/KotlinNullPointerException.KotlinNullPointerException|()"]; + 16 [label="Function call: R|java/lang/Exception.Exception|()"]; + 17 [label="Throw: throw R|java/lang/Exception.Exception|()"]; 18 [label="Stub" style="filled" fillcolor=gray]; 19 [label="Exit block" style="filled" fillcolor=gray]; } @@ -118,7 +118,7 @@ digraph jumps_kt { } 48 [label="Variable declaration: lval y: R|kotlin/Int?|"]; 49 [label="Access variable R|/y|"]; - 50 [label="Function call: R|/y|.#()"]; + 50 [label="Function call: R|/y|.#()"]; 51 [label="Exit function test_2" style="filled" fillcolor=red]; } diff --git a/compiler/fir/resolve/testData/resolve/cfg/jumps.kt b/compiler/fir/resolve/testData/resolve/cfg/jumps.kt index a950e9593b3..126031fbd59 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/jumps.kt +++ b/compiler/fir/resolve/testData/resolve/cfg/jumps.kt @@ -1,6 +1,7 @@ +// !DUMP_CFG fun test_1(x: Int?) { val y = if (x == null) { - throw KotlinNullPointerException() + throw Exception() } else { x } @@ -14,7 +15,7 @@ fun test_2(x: Int?) { } else { x } - y.inc() + y.inc() } fun test_3(x: Int?) { diff --git a/compiler/fir/resolve/testData/resolve/cfg/jumps.txt b/compiler/fir/resolve/testData/resolve/cfg/jumps.txt index d6289a9fbab..e1af89bd0a7 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/jumps.txt +++ b/compiler/fir/resolve/testData/resolve/cfg/jumps.txt @@ -2,7 +2,7 @@ FILE: jumps.kt public final fun test_1(x: R|kotlin/Int?|): R|kotlin/Unit| { lval y: R|kotlin/Int| = when () { ==(R|/x|, Null(null)) -> { - throw R|kotlin/KotlinNullPointerException.KotlinNullPointerException|() + throw R|java/lang/Exception.Exception|() } else -> { R|/x| @@ -22,7 +22,7 @@ FILE: jumps.kt } } - R|/y|.#() + R|/y|.#() } public final fun test_3(x: R|kotlin/Int?|): R|kotlin/Unit| { while(Boolean(true)) { diff --git a/compiler/fir/resolve/testData/resolve/cfg/jumps_0.dot b/compiler/fir/resolve/testData/resolve/cfg/jumps_0.dot deleted file mode 100644 index 1607c2c3b4e..00000000000 --- a/compiler/fir/resolve/testData/resolve/cfg/jumps_0.dot +++ /dev/null @@ -1,363 +0,0 @@ -digraph jumps_kt { - graph [splines=ortho nodesep=3] - node [shape=box penwidth=2] - edge [penwidth=2] - - subgraph cluster_0 { - color=red - 0 [label="Enter function test_1" style="filled" fillcolor=red]; - subgraph cluster_1 { - color=blue - 1 [label="Enter when"]; - subgraph cluster_2 { - color=blue - 2 [label="Enter when branch condition "]; - 3 [label="Access variable R|/x|"]; - 4 [label="Const: Null(null)"]; - 5 [label="Operator =="]; - 6 [label="Exit when branch condition"]; - } - subgraph cluster_3 { - color=blue - 7 [label="Enter when branch condition else"]; - 8 [label="Exit when branch condition"]; - } - 9 [label="Enter when branch result"]; - subgraph cluster_4 { - color=blue - 10 [label="Enter block"]; - 11 [label="Access variable R|/x|"]; - 12 [label="Exit block"]; - } - 13 [label="Exit when branch result"]; - 14 [label="Enter when branch result"]; - subgraph cluster_5 { - color=blue - 15 [label="Enter block"]; - 16 [label="Function call: R|kotlin/KotlinNullPointerException.KotlinNullPointerException|()"]; - 17 [label="Throw: throw R|kotlin/KotlinNullPointerException.KotlinNullPointerException|()"]; - 18 [label="Stub" style="filled" fillcolor=gray]; - 19 [label="Exit block" style="filled" fillcolor=gray]; - } - 20 [label="Exit when branch result" style="filled" fillcolor=gray]; - 21 [label="Exit when"]; - } - 22 [label="Variable declaration: lval y: R|kotlin/Int|"]; - 23 [label="Access variable R|/y|"]; - 24 [label="Function call: R|/y|.R|kotlin/Int.inc|()"]; - 25 [label="Access variable R|/x|"]; - 26 [label="Function call: R|/x|.R|kotlin/Int.inc|()"]; - 27 [label="Exit function test_1" style="filled" fillcolor=red]; - } - - 0 -> {1}; - 1 -> {2}; - 2 -> {3}; - 3 -> {4}; - 4 -> {5}; - 5 -> {6}; - 6 -> {14 7}; - 7 -> {8}; - 8 -> {9}; - 9 -> {10}; - 10 -> {11}; - 11 -> {12}; - 12 -> {13}; - 13 -> {21}; - 14 -> {15}; - 15 -> {16}; - 16 -> {17}; - 17 -> {27}; - 17 -> {18} [style=dotted]; - 18 -> {19} [style=dotted]; - 19 -> {20} [style=dotted]; - 20 -> {21} [style=dotted]; - 21 -> {22}; - 22 -> {23}; - 23 -> {24}; - 24 -> {25}; - 25 -> {26}; - 26 -> {27}; - - subgraph cluster_6 { - color=red - 28 [label="Enter function test_2" style="filled" fillcolor=red]; - subgraph cluster_7 { - color=blue - 29 [label="Enter when"]; - subgraph cluster_8 { - color=blue - 30 [label="Enter when branch condition "]; - 31 [label="Access variable R|/x|"]; - 32 [label="Const: Null(null)"]; - 33 [label="Operator =="]; - 34 [label="Exit when branch condition"]; - } - subgraph cluster_9 { - color=blue - 35 [label="Enter when branch condition else"]; - 36 [label="Exit when branch condition"]; - } - 37 [label="Enter when branch result"]; - subgraph cluster_10 { - color=blue - 38 [label="Enter block"]; - 39 [label="Access variable R|/x|"]; - 40 [label="Exit block"]; - } - 41 [label="Exit when branch result"]; - 42 [label="Enter when branch result"]; - subgraph cluster_11 { - color=blue - 43 [label="Enter block"]; - 44 [label="Access variable R|/x|"]; - 45 [label="Exit block"]; - } - 46 [label="Exit when branch result"]; - 47 [label="Exit when"]; - } - 48 [label="Variable declaration: lval y: R|kotlin/Int?|"]; - 49 [label="Access variable R|/y|"]; - 50 [label="Function call: R|/y|.#()"]; - 51 [label="Exit function test_2" style="filled" fillcolor=red]; - } - - 28 -> {29}; - 29 -> {30}; - 30 -> {31}; - 31 -> {32}; - 32 -> {33}; - 33 -> {34}; - 34 -> {42 35}; - 35 -> {36}; - 36 -> {37}; - 37 -> {38}; - 38 -> {39}; - 39 -> {40}; - 40 -> {41}; - 41 -> {47}; - 42 -> {43}; - 43 -> {44}; - 44 -> {45}; - 45 -> {46}; - 46 -> {47}; - 47 -> {48}; - 48 -> {49}; - 49 -> {50}; - 50 -> {51}; - - subgraph cluster_12 { - color=red - 52 [label="Enter function test_3" style="filled" fillcolor=red]; - subgraph cluster_13 { - color=blue - 53 [label="Enter while loop"]; - subgraph cluster_14 { - color=blue - 54 [label="Enter loop condition"]; - 55 [label="Const: Boolean(true)"]; - 56 [label="Exit loop condition"]; - } - subgraph cluster_15 { - color=blue - 57 [label="Enter loop block"]; - subgraph cluster_16 { - color=blue - 58 [label="Enter block"]; - 59 [label="Access variable R|/x|"]; - 60 [label="Type operator: x as Int"]; - 61 [label="Jump: break@@@[Boolean(true)] "]; - 62 [label="Stub" style="filled" fillcolor=gray]; - 63 [label="Exit block" style="filled" fillcolor=gray]; - } - 64 [label="Exit loop block" style="filled" fillcolor=gray]; - } - 65 [label="Stub" style="filled" fillcolor=gray]; - 66 [label="Exit whileloop"]; - } - 67 [label="Access variable R|/x|"]; - 68 [label="Function call: R|/x|.R|kotlin/Int.inc|()"]; - 69 [label="Exit function test_3" style="filled" fillcolor=red]; - } - - 52 -> {53}; - 53 -> {54}; - 54 -> {55}; - 55 -> {56}; - 56 -> {57}; - 56 -> {65} [style=dotted]; - 57 -> {58}; - 58 -> {59}; - 59 -> {60}; - 60 -> {61}; - 61 -> {66}; - 61 -> {62} [style=dotted]; - 62 -> {63} [style=dotted]; - 63 -> {64} [style=dotted]; - 64 -> {54} [style=dotted]; - 65 -> {66} [style=dotted]; - 66 -> {67}; - 67 -> {68}; - 68 -> {69}; - - subgraph cluster_17 { - color=red - 70 [label="Enter function test_4" style="filled" fillcolor=red]; - subgraph cluster_18 { - color=blue - 71 [label="Enter do-while loop"]; - subgraph cluster_19 { - color=blue - 72 [label="Enter loop block"]; - subgraph cluster_20 { - color=blue - 73 [label="Enter block"]; - 74 [label="Access variable R|/x|"]; - 75 [label="Type operator: x as Int"]; - 76 [label="Jump: break@@@[Boolean(true)] "]; - 77 [label="Stub" style="filled" fillcolor=gray]; - 78 [label="Exit block" style="filled" fillcolor=gray]; - } - 79 [label="Exit loop block" style="filled" fillcolor=gray]; - } - subgraph cluster_21 { - color=blue - 80 [label="Enter loop condition" style="filled" fillcolor=gray]; - 81 [label="Const: Boolean(true)" style="filled" fillcolor=gray]; - 82 [label="Exit loop condition" style="filled" fillcolor=gray]; - } - 83 [label="Stub" style="filled" fillcolor=gray]; - 84 [label="Exit do-whileloop"]; - } - 85 [label="Access variable R|/x|"]; - 86 [label="Function call: R|/x|.R|kotlin/Int.inc|()"]; - 87 [label="Exit function test_4" style="filled" fillcolor=red]; - } - - 70 -> {71}; - 71 -> {72}; - 72 -> {73}; - 73 -> {74}; - 74 -> {75}; - 75 -> {76}; - 76 -> {84}; - 76 -> {77} [style=dotted]; - 77 -> {78} [style=dotted]; - 78 -> {79} [style=dotted]; - 79 -> {80} [style=dotted]; - 80 -> {81} [style=dotted]; - 81 -> {82} [style=dotted]; - 82 -> {72 83} [style=dotted]; - 83 -> {84} [style=dotted]; - 84 -> {85}; - 85 -> {86}; - 86 -> {87}; - - subgraph cluster_22 { - color=red - 88 [label="Enter function test_5" style="filled" fillcolor=red]; - subgraph cluster_23 { - color=blue - 89 [label="Enter while loop"]; - subgraph cluster_24 { - color=blue - 90 [label="Enter loop condition"]; - 91 [label="Access variable R|/b|"]; - 92 [label="Exit loop condition"]; - } - subgraph cluster_25 { - color=blue - 93 [label="Enter loop block"]; - subgraph cluster_26 { - color=blue - 94 [label="Enter block"]; - subgraph cluster_27 { - color=blue - 95 [label="Enter when"]; - subgraph cluster_28 { - color=blue - 96 [label="Enter when branch condition "]; - 97 [label="Access variable R|/b|"]; - 98 [label="Exit when branch condition"]; - } - 99 [label="Synthetic else branch"]; - 100 [label="Enter when branch result"]; - subgraph cluster_29 { - color=blue - 101 [label="Enter block"]; - 102 [label="Jump: continue@@@[R|/b|] "]; - 103 [label="Stub" style="filled" fillcolor=gray]; - 104 [label="Exit block" style="filled" fillcolor=gray]; - } - 105 [label="Exit when branch result" style="filled" fillcolor=gray]; - 106 [label="Exit when"]; - } - 107 [label="Exit block"]; - } - 108 [label="Exit loop block"]; - } - 109 [label="Exit whileloop"]; - } - 110 [label="Exit function test_5" style="filled" fillcolor=red]; - } - - 88 -> {89}; - 89 -> {90}; - 90 -> {91}; - 91 -> {92}; - 92 -> {109 93}; - 93 -> {94}; - 94 -> {95}; - 95 -> {96}; - 96 -> {97}; - 97 -> {98}; - 98 -> {100 99}; - 99 -> {106}; - 100 -> {101}; - 101 -> {102}; - 102 -> {89}; - 102 -> {103} [style=dotted]; - 103 -> {104} [style=dotted]; - 104 -> {105} [style=dotted]; - 105 -> {106} [style=dotted]; - 106 -> {107}; - 107 -> {108}; - 108 -> {90}; - 109 -> {110}; - - subgraph cluster_30 { - color=red - 111 [label="Enter function run" style="filled" fillcolor=red]; - 112 [label="Function call: R|/block|.R|FakeOverride|()"]; - 113 [label="Exit function run" style="filled" fillcolor=red]; - } - - 111 -> {112}; - 112 -> {113}; - - subgraph cluster_31 { - color=red - 114 [label="Enter function test_6" style="filled" fillcolor=red]; - subgraph cluster_32 { - color=blue - 115 [label="Enter function anonymousFunction"]; - 116 [label="Jump: ^@run Unit"]; - 117 [label="Stub" style="filled" fillcolor=gray]; - 118 [label="Exit function anonymousFunction"]; - } - 119 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| { - ^@run Unit -} -)"]; - 120 [label="Exit function test_6" style="filled" fillcolor=red]; - } - - 114 -> {115}; - 115 -> {118 116}; - 116 -> {118}; - 116 -> {117} [style=dotted]; - 117 -> {118} [style=dotted]; - 118 -> {115 119}; - 119 -> {120}; - -} diff --git a/compiler/fir/resolve/testData/resolve/cfg/jumps_1.dot b/compiler/fir/resolve/testData/resolve/cfg/jumps_1.dot deleted file mode 100644 index f38b67659e3..00000000000 --- a/compiler/fir/resolve/testData/resolve/cfg/jumps_1.dot +++ /dev/null @@ -1,358 +0,0 @@ -digraph jumps_kt { - graph [splines=ortho nodesep=3] - node [shape=box penwidth=2] - edge [penwidth=2] - - subgraph cluster_0 { - color=red - 0 [label="Enter function test_1" style="filled" fillcolor=red]; - subgraph cluster_1 { - color=blue - 1 [label="Enter when"]; - subgraph cluster_2 { - color=blue - 2 [label="Enter when branch condition "]; - 3 [label="Access variable R|/x|"]; - 4 [label="Const: Null(null)"]; - 5 [label="Operator =="]; - 6 [label="Exit when branch condition"]; - } - subgraph cluster_3 { - color=blue - 7 [label="Enter when branch condition else"]; - 8 [label="Exit when branch condition"]; - } - 9 [label="Enter when branch result"]; - subgraph cluster_4 { - color=blue - 10 [label="Enter block"]; - 11 [label="Access variable R|/x|"]; - 12 [label="Exit block"]; - } - 13 [label="Exit when branch result"]; - 14 [label="Enter when branch result"]; - subgraph cluster_5 { - color=blue - 15 [label="Enter block"]; - 16 [label="Function call: R|kotlin/KotlinNullPointerException.KotlinNullPointerException|()"]; - 17 [label="Throw: throw R|kotlin/KotlinNullPointerException.KotlinNullPointerException|()"]; - 18 [label="Stub" style="filled" fillcolor=gray]; - 19 [label="Exit block" style="filled" fillcolor=gray]; - } - 20 [label="Exit when branch result" style="filled" fillcolor=gray]; - 21 [label="Exit when"]; - } - 22 [label="Variable declaration: lval y: R|kotlin/Int|"]; - 23 [label="Access variable R|/y|"]; - 24 [label="Function call: R|/y|.R|kotlin/Int.inc|()"]; - 25 [label="Access variable R|/x|"]; - 26 [label="Function call: R|/x|.R|kotlin/Int.inc|()"]; - 27 [label="Exit function test_1" style="filled" fillcolor=red]; - } - - 0 -> {1}; - 1 -> {2}; - 2 -> {3}; - 3 -> {4}; - 4 -> {5}; - 5 -> {6}; - 6 -> {14 7}; - 7 -> {8}; - 8 -> {9}; - 9 -> {10}; - 10 -> {11}; - 11 -> {12}; - 12 -> {13}; - 13 -> {21}; - 14 -> {15}; - 15 -> {16}; - 16 -> {17}; - 17 -> {27}; - 17 -> {18} [style=dotted]; - 18 -> {19} [style=dotted]; - 19 -> {20} [style=dotted]; - 20 -> {21} [style=dotted]; - 21 -> {22}; - 22 -> {23}; - 23 -> {24}; - 24 -> {25}; - 25 -> {26}; - 26 -> {27}; - - subgraph cluster_6 { - color=red - 28 [label="Enter function test_2" style="filled" fillcolor=red]; - subgraph cluster_7 { - color=blue - 29 [label="Enter when"]; - subgraph cluster_8 { - color=blue - 30 [label="Enter when branch condition "]; - 31 [label="Access variable R|/x|"]; - 32 [label="Const: Null(null)"]; - 33 [label="Operator =="]; - 34 [label="Exit when branch condition"]; - } - subgraph cluster_9 { - color=blue - 35 [label="Enter when branch condition else"]; - 36 [label="Exit when branch condition"]; - } - 37 [label="Enter when branch result"]; - subgraph cluster_10 { - color=blue - 38 [label="Enter block"]; - 39 [label="Access variable R|/x|"]; - 40 [label="Exit block"]; - } - 41 [label="Exit when branch result"]; - 42 [label="Enter when branch result"]; - subgraph cluster_11 { - color=blue - 43 [label="Enter block"]; - 44 [label="Access variable R|/x|"]; - 45 [label="Exit block"]; - } - 46 [label="Exit when branch result"]; - 47 [label="Exit when"]; - } - 48 [label="Variable declaration: lval y: R|kotlin/Int?|"]; - 49 [label="Access variable R|/y|"]; - 50 [label="Function call: R|/y|.#()"]; - 51 [label="Exit function test_2" style="filled" fillcolor=red]; - } - - 28 -> {29}; - 29 -> {30}; - 30 -> {31}; - 31 -> {32}; - 32 -> {33}; - 33 -> {34}; - 34 -> {42 35}; - 35 -> {36}; - 36 -> {37}; - 37 -> {38}; - 38 -> {39}; - 39 -> {40}; - 40 -> {41}; - 41 -> {47}; - 42 -> {43}; - 43 -> {44}; - 44 -> {45}; - 45 -> {46}; - 46 -> {47}; - 47 -> {48}; - 48 -> {49}; - 49 -> {50}; - 50 -> {51}; - - subgraph cluster_12 { - color=red - 52 [label="Enter function test_3" style="filled" fillcolor=red]; - subgraph cluster_13 { - color=blue - 53 [label="Enter while loop"]; - subgraph cluster_14 { - color=blue - 54 [label="Enter loop condition"]; - 55 [label="Const: Boolean(true)"]; - 56 [label="Exit loop condition"]; - } - subgraph cluster_15 { - color=blue - 57 [label="Enter loop block"]; - subgraph cluster_16 { - color=blue - 58 [label="Enter block"]; - 59 [label="Access variable R|/x|"]; - 60 [label="Type operator: x as Int"]; - 61 [label="Jump: break@@@[Boolean(true)] "]; - 62 [label="Stub" style="filled" fillcolor=gray]; - 63 [label="Exit block" style="filled" fillcolor=gray]; - } - 64 [label="Exit loop block" style="filled" fillcolor=gray]; - } - 65 [label="Exit whileloop"]; - } - 66 [label="Access variable R|/x|"]; - 67 [label="Function call: R|/x|.R|kotlin/Int.inc|()"]; - 68 [label="Exit function test_3" style="filled" fillcolor=red]; - } - - 52 -> {53}; - 53 -> {54}; - 54 -> {55}; - 55 -> {56}; - 56 -> {65 57}; - 57 -> {58}; - 58 -> {59}; - 59 -> {60}; - 60 -> {61}; - 61 -> {65}; - 61 -> {62} [style=dotted]; - 62 -> {63} [style=dotted]; - 63 -> {64} [style=dotted]; - 64 -> {54} [style=dotted]; - 65 -> {66}; - 66 -> {67}; - 67 -> {68}; - - subgraph cluster_17 { - color=red - 69 [label="Enter function test_4" style="filled" fillcolor=red]; - subgraph cluster_18 { - color=blue - 70 [label="Enter do-while loop"]; - subgraph cluster_19 { - color=blue - 71 [label="Enter loop block"]; - subgraph cluster_20 { - color=blue - 72 [label="Enter block"]; - 73 [label="Access variable R|/x|"]; - 74 [label="Type operator: x as Int"]; - 75 [label="Jump: break@@@[Boolean(true)] "]; - 76 [label="Stub" style="filled" fillcolor=gray]; - 77 [label="Exit block" style="filled" fillcolor=gray]; - } - 78 [label="Exit loop block" style="filled" fillcolor=gray]; - } - subgraph cluster_21 { - color=blue - 79 [label="Enter loop condition" style="filled" fillcolor=gray]; - 80 [label="Const: Boolean(true)" style="filled" fillcolor=gray]; - 81 [label="Exit loop condition" style="filled" fillcolor=gray]; - } - 82 [label="Exit do-whileloop"]; - } - 83 [label="Access variable R|/x|"]; - 84 [label="Function call: R|/x|.R|kotlin/Int.inc|()"]; - 85 [label="Exit function test_4" style="filled" fillcolor=red]; - } - - 69 -> {70}; - 70 -> {71}; - 71 -> {72}; - 72 -> {73}; - 73 -> {74}; - 74 -> {75}; - 75 -> {82}; - 75 -> {76} [style=dotted]; - 76 -> {77} [style=dotted]; - 77 -> {78} [style=dotted]; - 78 -> {79} [style=dotted]; - 79 -> {80} [style=dotted]; - 80 -> {81} [style=dotted]; - 81 -> {71 82} [style=dotted]; - 82 -> {83}; - 83 -> {84}; - 84 -> {85}; - - subgraph cluster_22 { - color=red - 86 [label="Enter function test_5" style="filled" fillcolor=red]; - subgraph cluster_23 { - color=blue - 87 [label="Enter while loop"]; - subgraph cluster_24 { - color=blue - 88 [label="Enter loop condition"]; - 89 [label="Access variable R|/b|"]; - 90 [label="Exit loop condition"]; - } - subgraph cluster_25 { - color=blue - 91 [label="Enter loop block"]; - subgraph cluster_26 { - color=blue - 92 [label="Enter block"]; - subgraph cluster_27 { - color=blue - 93 [label="Enter when"]; - subgraph cluster_28 { - color=blue - 94 [label="Enter when branch condition "]; - 95 [label="Access variable R|/b|"]; - 96 [label="Exit when branch condition"]; - } - 97 [label="Synthetic else branch"]; - 98 [label="Enter when branch result"]; - subgraph cluster_29 { - color=blue - 99 [label="Enter block"]; - 100 [label="Jump: continue@@@[R|/b|] "]; - 101 [label="Stub" style="filled" fillcolor=gray]; - 102 [label="Exit block" style="filled" fillcolor=gray]; - } - 103 [label="Exit when branch result" style="filled" fillcolor=gray]; - 104 [label="Exit when"]; - } - 105 [label="Exit block"]; - } - 106 [label="Exit loop block"]; - } - 107 [label="Exit whileloop"]; - } - 108 [label="Exit function test_5" style="filled" fillcolor=red]; - } - - 86 -> {87}; - 87 -> {88}; - 88 -> {89}; - 89 -> {90}; - 90 -> {107 91}; - 91 -> {92}; - 92 -> {93}; - 93 -> {94}; - 94 -> {95}; - 95 -> {96}; - 96 -> {98 97}; - 97 -> {104}; - 98 -> {99}; - 99 -> {100}; - 100 -> {87}; - 100 -> {101} [style=dotted]; - 101 -> {102} [style=dotted]; - 102 -> {103} [style=dotted]; - 103 -> {104} [style=dotted]; - 104 -> {105}; - 105 -> {106}; - 106 -> {88}; - 107 -> {108}; - - subgraph cluster_30 { - color=red - 109 [label="Enter function run" style="filled" fillcolor=red]; - 110 [label="Function call: R|/block|.R|FakeOverride|()"]; - 111 [label="Exit function run" style="filled" fillcolor=red]; - } - - 109 -> {110}; - 110 -> {111}; - - subgraph cluster_31 { - color=red - 112 [label="Enter function test_6" style="filled" fillcolor=red]; - subgraph cluster_32 { - color=blue - 113 [label="Enter function anonymousFunction"]; - 114 [label="Jump: ^@run Unit"]; - 115 [label="Stub" style="filled" fillcolor=gray]; - 116 [label="Exit function anonymousFunction"]; - } - 117 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| { - ^@run Unit -} -)"]; - 118 [label="Exit function test_6" style="filled" fillcolor=red]; - } - - 112 -> {113}; - 113 -> {116 114}; - 114 -> {116}; - 114 -> {115} [style=dotted]; - 115 -> {116} [style=dotted]; - 116 -> {113 117}; - 117 -> {118}; - -} diff --git a/compiler/fir/resolve/testData/resolve/cfg/lambdas.kt b/compiler/fir/resolve/testData/resolve/cfg/lambdas.kt index d3395da52c1..30d284754b0 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/lambdas.kt +++ b/compiler/fir/resolve/testData/resolve/cfg/lambdas.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG inline fun run(block: () -> Unit) { block() } diff --git a/compiler/fir/resolve/testData/resolve/cfg/loops.kt b/compiler/fir/resolve/testData/resolve/cfg/loops.kt index b52562e0edc..f46fd20a6a4 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/loops.kt +++ b/compiler/fir/resolve/testData/resolve/cfg/loops.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG fun testWhile(b: Boolean, x: Any?) { while (b) { val y = x is String diff --git a/compiler/fir/resolve/testData/resolve/cfg/postponedLambdas.kt b/compiler/fir/resolve/testData/resolve/cfg/postponedLambdas.kt index 26b6d504551..50bb00666ea 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/postponedLambdas.kt +++ b/compiler/fir/resolve/testData/resolve/cfg/postponedLambdas.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG inline fun foo(vararg x: Any) {} fun test(a: Any, b: Any, c: Any) { diff --git a/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.kt b/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.kt index d446cce0028..15c4611b86b 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.kt +++ b/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG inline fun run(block: () -> Unit) { block() } diff --git a/compiler/fir/resolve/testData/resolve/cfg/returnValuesFromLambda.kt b/compiler/fir/resolve/testData/resolve/cfg/returnValuesFromLambda.kt index ec80640b8da..a8a716d7145 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/returnValuesFromLambda.kt +++ b/compiler/fir/resolve/testData/resolve/cfg/returnValuesFromLambda.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG interface A class B : A diff --git a/compiler/fir/resolve/testData/resolve/cfg/safeCalls.kt b/compiler/fir/resolve/testData/resolve/cfg/safeCalls.kt index e00f9d30b2e..e17b7a1c802 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/safeCalls.kt +++ b/compiler/fir/resolve/testData/resolve/cfg/safeCalls.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG interface A { fun foo(): A fun bar(): A diff --git a/compiler/fir/resolve/testData/resolve/cfg/simple.kt b/compiler/fir/resolve/testData/resolve/cfg/simple.kt index 17e3f2774b4..b15a7ff84a5 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/simple.kt +++ b/compiler/fir/resolve/testData/resolve/cfg/simple.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG fun foo() {} fun test() { diff --git a/compiler/fir/resolve/testData/resolve/cfg/tryCatch.kt b/compiler/fir/resolve/testData/resolve/cfg/tryCatch.kt index 66cd1bcef0b..753b04f5373 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/tryCatch.kt +++ b/compiler/fir/resolve/testData/resolve/cfg/tryCatch.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG fun test_1() { try { val x = 1 diff --git a/compiler/fir/resolve/testData/resolve/cfg/when.kt b/compiler/fir/resolve/testData/resolve/cfg/when.kt index 478098e3817..fc052120c6d 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/when.kt +++ b/compiler/fir/resolve/testData/resolve/cfg/when.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG fun test_1(x: Int) { val y = when { x == 1 -> 10 diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/bangbang.kt b/compiler/fir/resolve/testData/resolve/smartcasts/bangbang.kt index 50b2badee5d..6c778107ba5 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/bangbang.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/bangbang.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG interface A { fun foo(): Boolean } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/booleans/booleanOperators.kt b/compiler/fir/resolve/testData/resolve/smartcasts/booleans/booleanOperators.kt index c77cf53627f..48970dce5b7 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/booleans/booleanOperators.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/booleans/booleanOperators.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG interface A { fun foo() diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/booleans/equalsToBoolean.kt b/compiler/fir/resolve/testData/resolve/smartcasts/booleans/equalsToBoolean.kt index 3ff1aa1fb7d..045d3fa1779 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/booleans/equalsToBoolean.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/booleans/equalsToBoolean.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG interface A { fun foo() val b: Boolean diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.dot b/compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.dot index c4c2668e0dd..42c31acfce4 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.dot +++ b/compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.dot @@ -223,7 +223,7 @@ digraph boundSmartcasts_kt { 83 [label="Access variable R|/y|"]; 84 [label="Assignmenet: R|/x|"]; 85 [label="Access variable R|/x|"]; - 86 [label="Function call: R|/x|.#()"]; + 86 [label="Function call: R|/x|.#()"]; subgraph cluster_18 { color=blue 87 [label="Enter when"]; diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.kt b/compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.kt index b68d1a8c135..2642e666098 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG interface A { fun foo() } @@ -39,7 +40,7 @@ fun test_4(y: Any) { x as Int x.inc() x = y - x.inc() + x.inc() if (y is A) { x.foo() y.foo() diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.txt b/compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.txt index ce8ee033138..f0321386142 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.txt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.txt @@ -49,7 +49,7 @@ FILE: boundSmartcasts.kt (R|/x| as R|kotlin/Int|) R|/x|.R|kotlin/Int.inc|() R|/x| = R|/y| - R|/x|.#() + R|/x|.#() when () { (R|/y| is R|A|) -> { R|/x|.R|/A.foo|() diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastsInBranches.kt b/compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastsInBranches.kt index cd1ca76d80d..33e8f4b3cb4 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastsInBranches.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastsInBranches.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG class A { val s: String = "" } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/casts.kt b/compiler/fir/resolve/testData/resolve/smartcasts/casts.kt index 7ccaebc0256..75224175da3 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/casts.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/casts.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG fun test_1(x: Any?) { x as String x.length diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/elvis.kt b/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/elvis.kt index b8a31666e1b..cdcbaa5f77c 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/elvis.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/elvis.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG interface A { fun foo() val b: Boolean diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/returns.dot b/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/returns.dot index ecc2ae48ed3..4cce3d9b2c7 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/returns.dot +++ b/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/returns.dot @@ -427,8 +427,8 @@ digraph returns_kt { 161 [label="Variable declaration: lval length: R|kotlin/Int|"]; 162 [label="Postponed enter to lambda"]; 163 [label="Postponed exit from lambda"]; - 164 [label="Function call: R|/runHigherOrder|( = runHigherOrder@fun (): R|kotlin/Boolean| { - ^ R|/s|.R|kotlin/text/isNotEmpty|() + 164 [label="Function call: R|/runHigherOrder|( = runHigherOrder@fun (): R|kotlin/Int| { + ^ R|/s|.R|kotlin/String.length| } )"]; 165 [label="Exit function test_4" style="filled" fillcolor=red]; @@ -472,7 +472,7 @@ digraph returns_kt { color=red 166 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; 167 [label="Access variable R|/s|"]; - 168 [label="Function call: R|/s|.R|kotlin/text/isNotEmpty|()"]; + 168 [label="Access variable R|kotlin/String.length|"]; 169 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/returns.kt b/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/returns.kt index e88de7b7fb9..71d27f73d39 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/returns.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/returns.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG fun test_0(x: Any) { if (x is String) { x.length @@ -57,6 +58,6 @@ fun test_4(a: Any?) { val s = a as? String val length = s?.ext ?: return runHigherOrder { - s.isNotEmpty() // Should be OK + s.length // Should be OK } } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/returns.txt b/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/returns.txt index aa455f7dacd..2f091f5ef73 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/returns.txt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/returns.txt @@ -83,8 +83,8 @@ FILE: returns.kt } } - R|/runHigherOrder|( = runHigherOrder@fun (): R|kotlin/Boolean| { - ^ R|/s|.R|kotlin/text/isNotEmpty|() + R|/runHigherOrder|( = runHigherOrder@fun (): R|kotlin/Int| { + ^ R|/s|.R|kotlin/String.length| } ) } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/simpleIf.kt b/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/simpleIf.kt index d2d2da7be00..bbe6b2244b2 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/simpleIf.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/simpleIf.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG fun test_1(x: Any) { if (x is String) { x.length diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/smartcastFromArgument.kt b/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/smartcastFromArgument.kt index fb74156ae80..07d628f7306 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/smartcastFromArgument.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/smartcastFromArgument.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG interface A { fun foo() } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/when.kt b/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/when.kt index 587bb5c90df..b5a9a67bab0 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/when.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/when.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG interface A { fun foo() } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/equalsAndIdentity.kt b/compiler/fir/resolve/testData/resolve/smartcasts/equalsAndIdentity.kt index b0371ed8143..18289e801d8 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/equalsAndIdentity.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/equalsAndIdentity.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG interface A { fun foo() } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/lambdas/inPlaceLambdas.kt b/compiler/fir/resolve/testData/resolve/smartcasts/lambdas/inPlaceLambdas.kt index 9cb045b988a..814a05ded5e 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/lambdas/inPlaceLambdas.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/lambdas/inPlaceLambdas.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG interface A { fun foo() } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/lambdas/smartcastOnLambda.kt b/compiler/fir/resolve/testData/resolve/smartcasts/lambdas/smartcastOnLambda.kt index 27c25564797..0ee6af5b03c 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/lambdas/smartcastOnLambda.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/lambdas/smartcastOnLambda.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG fun test(func: (() -> Unit)?) { if (func != null) { func() diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/loops/dataFlowInfoFromWhileCondition.kt b/compiler/fir/resolve/testData/resolve/smartcasts/loops/dataFlowInfoFromWhileCondition.kt index 3f9ac9c4502..fe66111c930 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/loops/dataFlowInfoFromWhileCondition.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/loops/dataFlowInfoFromWhileCondition.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG interface A { fun foo(): Boolean } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/loops/endlessLoops.kt b/compiler/fir/resolve/testData/resolve/smartcasts/loops/endlessLoops.kt index 83758a1d4ff..1776f00f971 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/loops/endlessLoops.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/loops/endlessLoops.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG interface A { fun foo() } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/multipleCasts.kt b/compiler/fir/resolve/testData/resolve/smartcasts/multipleCasts.kt index 7638385bc1a..d264337c942 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/multipleCasts.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/multipleCasts.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG // There would be ambiguities if some expression was smartcasted to (A & B) and foo() was called. // There was a bug where 2 variables were "bound" together if they are assigned from the same function call or property. interface A { diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/nullability.dot b/compiler/fir/resolve/testData/resolve/smartcasts/nullability.dot index 053015f6303..a0c28ca3c88 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/nullability.dot +++ b/compiler/fir/resolve/testData/resolve/smartcasts/nullability.dot @@ -503,7 +503,7 @@ digraph nullability_kt { 176 [label="Access variable R|/q|"]; 177 [label="Access variable R|/Q.data|"]; 178 [label="Access variable #"]; - 179 [label="Function call: R|/q|.R|/Q.data|.#.#()"]; + 179 [label="Function call: R|/q|.R|/Q.data|.#.#()"]; 180 [label="Exit block"]; } 181 [label="Exit when branch result"]; @@ -600,7 +600,7 @@ digraph nullability_kt { 220 [label="Access variable R|/q|"]; 221 [label="Access variable R|/Q.data|"]; 222 [label="Access variable #"]; - 223 [label="Function call: R|/q|.R|/Q.data|.#.#()"]; + 223 [label="Function call: R|/q|.R|/Q.data|.#.#()"]; 224 [label="Exit function test_6" style="filled" fillcolor=red]; } @@ -682,7 +682,7 @@ digraph nullability_kt { 249 [label="Access variable R|/q|"]; 250 [label="Function call: R|/q|.R|/Q.fdata|()"]; 251 [label="Function call: R|/q|.R|/Q.fdata|().#()"]; - 252 [label="Function call: R|/q|.R|/Q.fdata|().#().#()"]; + 252 [label="Function call: R|/q|.R|/Q.fdata|().#().#()"]; 253 [label="Exit block"]; } 254 [label="Exit when branch result"]; @@ -795,7 +795,7 @@ digraph nullability_kt { 287 [label="Exit when"]; } 288 [label="Access variable R|/b|"]; - 289 [label="Function call: R|/b|.#()"]; + 289 [label="Function call: R|/b|.#()"]; subgraph cluster_65 { color=blue 290 [label="Enter when"]; @@ -820,7 +820,7 @@ digraph nullability_kt { 303 [label="Exit when"]; } 304 [label="Access variable R|/b|"]; - 305 [label="Function call: R|/b|.#()"]; + 305 [label="Function call: R|/b|.#()"]; subgraph cluster_68 { color=blue 306 [label="Enter when"]; @@ -845,7 +845,7 @@ digraph nullability_kt { 319 [label="Exit when"]; } 320 [label="Access variable R|/b|"]; - 321 [label="Function call: R|/b|.#()"]; + 321 [label="Function call: R|/b|.#()"]; subgraph cluster_71 { color=blue 322 [label="Enter when"]; @@ -870,7 +870,7 @@ digraph nullability_kt { 335 [label="Exit when"]; } 336 [label="Access variable R|/b|"]; - 337 [label="Function call: R|/b|.#()"]; + 337 [label="Function call: R|/b|.#()"]; 338 [label="Exit function test_9" style="filled" fillcolor=red]; } @@ -960,14 +960,14 @@ digraph nullability_kt { color=blue 348 [label="Enter block"]; 349 [label="Access variable R|/b|"]; - 350 [label="Function call: R|/b|.#()"]; + 350 [label="Function call: R|/b|.#()"]; 351 [label="Exit block"]; } 352 [label="Exit when branch result"]; 353 [label="Exit when"]; } 354 [label="Access variable R|/b|"]; - 355 [label="Function call: R|/b|.#()"]; + 355 [label="Function call: R|/b|.#()"]; subgraph cluster_78 { color=blue 356 [label="Enter when"]; @@ -985,14 +985,14 @@ digraph nullability_kt { color=blue 364 [label="Enter block"]; 365 [label="Access variable R|/b|"]; - 366 [label="Function call: R|/b|.#()"]; + 366 [label="Function call: R|/b|.#()"]; 367 [label="Exit block"]; } 368 [label="Exit when branch result"]; 369 [label="Exit when"]; } 370 [label="Access variable R|/b|"]; - 371 [label="Function call: R|/b|.#()"]; + 371 [label="Function call: R|/b|.#()"]; subgraph cluster_81 { color=blue 372 [label="Enter when"]; @@ -1010,14 +1010,14 @@ digraph nullability_kt { color=blue 380 [label="Enter block"]; 381 [label="Access variable R|/b|"]; - 382 [label="Function call: R|/b|.#()"]; + 382 [label="Function call: R|/b|.#()"]; 383 [label="Exit block"]; } 384 [label="Exit when branch result"]; 385 [label="Exit when"]; } 386 [label="Access variable R|/b|"]; - 387 [label="Function call: R|/b|.#()"]; + 387 [label="Function call: R|/b|.#()"]; subgraph cluster_84 { color=blue 388 [label="Enter when"]; @@ -1035,14 +1035,14 @@ digraph nullability_kt { color=blue 396 [label="Enter block"]; 397 [label="Access variable R|/b|"]; - 398 [label="Function call: R|/b|.#()"]; + 398 [label="Function call: R|/b|.#()"]; 399 [label="Exit block"]; } 400 [label="Exit when branch result"]; 401 [label="Exit when"]; } 402 [label="Access variable R|/b|"]; - 403 [label="Function call: R|/b|.#()"]; + 403 [label="Function call: R|/b|.#()"]; 404 [label="Exit function test_10" style="filled" fillcolor=red]; } @@ -1157,7 +1157,7 @@ digraph nullability_kt { 438 [label="Access variable R|/q2|"]; 439 [label="Access variable R|/QImpl.data|"]; 440 [label="Access variable #"]; - 441 [label="Function call: R|/q2|.R|/QImpl.data|.#.#()"]; + 441 [label="Function call: R|/q2|.R|/QImpl.data|.#.#()"]; subgraph cluster_91 { color=blue 442 [label="Enter when"]; @@ -1292,7 +1292,7 @@ digraph nullability_kt { 490 [label="Access variable R|/q|"]; 491 [label="Access variable R|/QImplWithCustomGetter.data|"]; 492 [label="Access variable #"]; - 493 [label="Function call: R|/q|.R|/QImplWithCustomGetter.data|.#.#()"]; + 493 [label="Function call: R|/q|.R|/QImplWithCustomGetter.data|.#.#()"]; 494 [label="Exit block"]; } 495 [label="Exit when branch result"]; @@ -1369,7 +1369,7 @@ digraph nullability_kt { 522 [label="Access variable R|/q|"]; 523 [label="Access variable R|/QImplMutable.data|"]; 524 [label="Access variable #"]; - 525 [label="Function call: R|/q|.R|/QImplMutable.data|.#.#()"]; + 525 [label="Function call: R|/q|.R|/QImplMutable.data|.#.#()"]; 526 [label="Exit block"]; } 527 [label="Exit when branch result"]; diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/nullability.kt b/compiler/fir/resolve/testData/resolve/smartcasts/nullability.kt index 0baed6a62bc..3df2ac9fb33 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/nullability.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/nullability.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG // CONTAINS ERRORS interface A { @@ -67,7 +68,7 @@ fun test_5(q: Q?) { if (q?.data?.s?.inc() != null) { q.data // good q.data.s // should be bad - q.data.s.inc() // should be bad + q.data.s.inc() // should be bad } } @@ -76,14 +77,14 @@ fun test_6(q: Q?) { q?.data?.s?.inc() ?: return q.data // good q.data.s // should be bad - q.data.s.inc() // should be bad + q.data.s.inc() // should be bad } fun test_7(q: Q?) { if (q?.fdata()?.fs()?.inc() != null) { q.fdata() // good q.fdata().fs() // bad - q.fdata().fs().inc() // bad + q.fdata().fs().inc() // bad } } @@ -97,44 +98,44 @@ fun test_9(a: Int, b: Int?) { if (a == b) { b.inc() } - b.inc() + b.inc() if (a === b) { b.inc() } - b.inc() + b.inc() if (b == a) { b.inc() } - b.inc() + b.inc() if (b === a) { b.inc() } - b.inc() + b.inc() } fun test_10(a: Int?, b: Int?) { if (a == b) { - b.inc() + b.inc() } - b.inc() + b.inc() if (a === b) { - b.inc() + b.inc() } - b.inc() + b.inc() if (b == a) { - b.inc() + b.inc() } - b.inc() + b.inc() if (b === a) { - b.inc() + b.inc() } - b.inc() + b.inc() } fun test_11(q: QImpl?, q2: QImpl) { @@ -148,7 +149,7 @@ fun test_11(q: QImpl?, q2: QImpl) { // Issue: Smartcasting of QImpl.data affects all instances q2.data q2.data.s // should be bad - q2.data.s.inc() // should be bad + q2.data.s.inc() // should be bad if (q2.data != null) { q2.data.s @@ -162,7 +163,7 @@ fun test_12(q: QImplWithCustomGetter?) { if (q?.data?.s?.inc() != null) { q.data // good q.data.s // should be bad - q.data.s.inc() // should be bad + q.data.s.inc() // should be bad } } @@ -171,6 +172,6 @@ fun test_13(q: QImplMutable?) { if (q?.data?.s?.inc() != null) { q.data // good q.data.s // should be bad - q.data.s.inc() // should be bad + q.data.s.inc() // should be bad } } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/nullability.txt b/compiler/fir/resolve/testData/resolve/smartcasts/nullability.txt index f63c7cf74cc..006ed3b0566 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/nullability.txt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/nullability.txt @@ -111,7 +111,7 @@ FILE: nullability.kt !=(R|/q|?.R|/Q.data|?.R|/MyData.s|?.R|kotlin/Int.inc|(), Null(null)) -> { R|/q|.R|/Q.data| R|/q|.R|/Q.data|.# - R|/q|.R|/Q.data|.#.#() + R|/q|.R|/Q.data|.#.#() } } @@ -128,14 +128,14 @@ FILE: nullability.kt R|/q|.R|/Q.data| R|/q|.R|/Q.data|.# - R|/q|.R|/Q.data|.#.#() + R|/q|.R|/Q.data|.#.#() } public final fun test_7(q: R|Q?|): R|kotlin/Unit| { when () { !=(R|/q|?.R|/Q.fdata|()?.R|/MyData.fs|()?.R|kotlin/Int.inc|(), Null(null)) -> { R|/q|.R|/Q.fdata|() R|/q|.R|/Q.fdata|().#() - R|/q|.R|/Q.fdata|().#().#() + R|/q|.R|/Q.fdata|().#().#() } } @@ -155,58 +155,58 @@ FILE: nullability.kt } } - R|/b|.#() + R|/b|.#() when () { ===(R|/a|, R|/b|) -> { R|/b|.R|kotlin/Int.inc|() } } - R|/b|.#() + R|/b|.#() when () { ==(R|/b|, R|/a|) -> { R|/b|.R|kotlin/Int.inc|() } } - R|/b|.#() + R|/b|.#() when () { ===(R|/b|, R|/a|) -> { R|/b|.R|kotlin/Int.inc|() } } - R|/b|.#() + R|/b|.#() } public final fun test_10(a: R|kotlin/Int?|, b: R|kotlin/Int?|): R|kotlin/Unit| { when () { ==(R|/a|, R|/b|) -> { - R|/b|.#() + R|/b|.#() } } - R|/b|.#() + R|/b|.#() when () { ===(R|/a|, R|/b|) -> { - R|/b|.#() + R|/b|.#() } } - R|/b|.#() + R|/b|.#() when () { ==(R|/b|, R|/a|) -> { - R|/b|.#() + R|/b|.#() } } - R|/b|.#() + R|/b|.#() when () { ===(R|/b|, R|/a|) -> { - R|/b|.#() + R|/b|.#() } } - R|/b|.#() + R|/b|.#() } public final fun test_11(q: R|QImpl?|, q2: R|QImpl|): R|kotlin/Unit| { when () { @@ -216,7 +216,7 @@ FILE: nullability.kt R|/q|.R|/QImpl.data|.R|/MyData.s|.R|kotlin/Int.inc|() R|/q2|.R|/QImpl.data| R|/q2|.R|/QImpl.data|.# - R|/q2|.R|/QImpl.data|.#.#() + R|/q2|.R|/QImpl.data|.#.#() when () { !=(R|/q2|.R|/QImpl.data|, Null(null)) -> { R|/q2|.R|/QImpl.data|.R|/MyData.s| @@ -233,7 +233,7 @@ FILE: nullability.kt !=(R|/q|?.R|/QImplWithCustomGetter.data|?.R|/MyData.s|?.R|kotlin/Int.inc|(), Null(null)) -> { R|/q|.R|/QImplWithCustomGetter.data| R|/q|.R|/QImplWithCustomGetter.data|.# - R|/q|.R|/QImplWithCustomGetter.data|.#.#() + R|/q|.R|/QImplWithCustomGetter.data|.#.#() } } @@ -243,7 +243,7 @@ FILE: nullability.kt !=(R|/q|?.R|/QImplMutable.data|?.R|/MyData.s|?.R|kotlin/Int.inc|(), Null(null)) -> { R|/q|.R|/QImplMutable.data| R|/q|.R|/QImplMutable.data|.# - R|/q|.R|/QImplMutable.data|.#.#() + R|/q|.R|/QImplMutable.data|.#.#() } } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/problems/smartcastOnBangBang.kt b/compiler/fir/resolve/testData/resolve/smartcasts/problems/smartcastOnBangBang.kt index 7cac4f782de..218de195848 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/problems/smartcastOnBangBang.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/problems/smartcastOnBangBang.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG fun test_1(a: X) { if (a is String?) { takeString(a!!) diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceiverAsWhenSubject.kt b/compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceiverAsWhenSubject.kt index 3951ea727ac..a06e2fa03a1 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceiverAsWhenSubject.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceiverAsWhenSubject.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG fun Any.test_1(): Int = when (this) { is List<*> -> this.size is String -> length diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceivers.kt b/compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceivers.kt index dae3c878b8d..23e50af2cc2 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceivers.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceivers.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG class A { fun foo() {} } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/receivers/thisOfExtensionProperty.kt b/compiler/fir/resolve/testData/resolve/smartcasts/receivers/thisOfExtensionProperty.kt index c276790a309..1194188e562 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/receivers/thisOfExtensionProperty.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/receivers/thisOfExtensionProperty.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG interface A interface B { @@ -9,4 +10,3 @@ val A.check_1: Boolean val A.check_2: Boolean get() = this is B && this.b -// 1713 \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/assignSafeCall.kt b/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/assignSafeCall.kt index 84f83a3b5d8..2498a8ed2f2 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/assignSafeCall.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/assignSafeCall.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG // ----------------- Stable ----------------- class A { diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.dot b/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.dot index 592070762c3..41dcdda0be2 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.dot +++ b/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.dot @@ -5,286 +5,301 @@ digraph safeCallAndEqualityToBool_kt { subgraph cluster_0 { color=red - 0 [label="Enter function test_1" style="filled" fillcolor=red]; - subgraph cluster_1 { - color=blue - 1 [label="Enter when"]; - subgraph cluster_2 { - color=blue - 2 [label="Enter when branch condition "]; - 3 [label="Access variable R|/s|"]; - 4 [label="Enter safe call"]; - 5 [label="Function call: R|/s|?.R|kotlin/text/isNotEmpty|()"]; - 6 [label="Exit safe call"]; - 7 [label="Const: Boolean(true)"]; - 8 [label="Operator =="]; - 9 [label="Exit when branch condition"]; - } - subgraph cluster_3 { - color=blue - 10 [label="Enter when branch condition else"]; - 11 [label="Exit when branch condition"]; - } - 12 [label="Enter when branch result"]; - subgraph cluster_4 { - color=blue - 13 [label="Enter block"]; - 14 [label="Access variable R|/s|"]; - 15 [label="Access variable #"]; - 16 [label="Exit block"]; - } - 17 [label="Exit when branch result"]; - 18 [label="Enter when branch result"]; - subgraph cluster_5 { - color=blue - 19 [label="Enter block"]; - 20 [label="Access variable R|/s|"]; - 21 [label="Access variable R|kotlin/String.length|"]; - 22 [label="Exit block"]; - } - 23 [label="Exit when branch result"]; - 24 [label="Exit when"]; - } - 25 [label="Exit function test_1" style="filled" fillcolor=red]; + 0 [label="Enter function check" style="filled" fillcolor=red]; + 1 [label="Const: Boolean(true)"]; + 2 [label="Jump: ^check Boolean(true)"]; + 3 [label="Stub" style="filled" fillcolor=gray]; + 4 [label="Exit function check" style="filled" fillcolor=red]; } 0 -> {1}; 1 -> {2}; - 2 -> {3}; - 3 -> {4 6}; - 4 -> {5}; + 2 -> {4}; + 2 -> {3} [style=dotted]; + 3 -> {4} [style=dotted]; + + subgraph cluster_1 { + color=red + 5 [label="Enter function test_1" style="filled" fillcolor=red]; + subgraph cluster_2 { + color=blue + 6 [label="Enter when"]; + subgraph cluster_3 { + color=blue + 7 [label="Enter when branch condition "]; + 8 [label="Access variable R|/s|"]; + 9 [label="Enter safe call"]; + 10 [label="Function call: R|/s|?.R|/check|()"]; + 11 [label="Exit safe call"]; + 12 [label="Const: Boolean(true)"]; + 13 [label="Operator =="]; + 14 [label="Exit when branch condition"]; + } + subgraph cluster_4 { + color=blue + 15 [label="Enter when branch condition else"]; + 16 [label="Exit when branch condition"]; + } + 17 [label="Enter when branch result"]; + subgraph cluster_5 { + color=blue + 18 [label="Enter block"]; + 19 [label="Access variable R|/s|"]; + 20 [label="Access variable #"]; + 21 [label="Exit block"]; + } + 22 [label="Exit when branch result"]; + 23 [label="Enter when branch result"]; + subgraph cluster_6 { + color=blue + 24 [label="Enter block"]; + 25 [label="Access variable R|/s|"]; + 26 [label="Access variable R|kotlin/String.length|"]; + 27 [label="Exit block"]; + } + 28 [label="Exit when branch result"]; + 29 [label="Exit when"]; + } + 30 [label="Exit function test_1" style="filled" fillcolor=red]; + } + 5 -> {6}; 6 -> {7}; 7 -> {8}; - 8 -> {9}; - 9 -> {18 10}; + 8 -> {9 11}; + 9 -> {10}; 10 -> {11}; 11 -> {12}; 12 -> {13}; 13 -> {14}; - 14 -> {15}; + 14 -> {23 15}; 15 -> {16}; 16 -> {17}; - 17 -> {24}; + 17 -> {18}; 18 -> {19}; 19 -> {20}; 20 -> {21}; 21 -> {22}; - 22 -> {23}; + 22 -> {29}; 23 -> {24}; 24 -> {25}; - - subgraph cluster_6 { - color=red - 26 [label="Enter function test_2" style="filled" fillcolor=red]; - subgraph cluster_7 { - color=blue - 27 [label="Enter when"]; - subgraph cluster_8 { - color=blue - 28 [label="Enter when branch condition "]; - 29 [label="Access variable R|/s|"]; - 30 [label="Enter safe call"]; - 31 [label="Function call: R|/s|?.R|kotlin/text/isNotEmpty|()"]; - 32 [label="Exit safe call"]; - 33 [label="Const: Boolean(false)"]; - 34 [label="Operator =="]; - 35 [label="Exit when branch condition"]; - } - subgraph cluster_9 { - color=blue - 36 [label="Enter when branch condition else"]; - 37 [label="Exit when branch condition"]; - } - 38 [label="Enter when branch result"]; - subgraph cluster_10 { - color=blue - 39 [label="Enter block"]; - 40 [label="Access variable R|/s|"]; - 41 [label="Access variable #"]; - 42 [label="Exit block"]; - } - 43 [label="Exit when branch result"]; - 44 [label="Enter when branch result"]; - subgraph cluster_11 { - color=blue - 45 [label="Enter block"]; - 46 [label="Access variable R|/s|"]; - 47 [label="Access variable R|kotlin/String.length|"]; - 48 [label="Exit block"]; - } - 49 [label="Exit when branch result"]; - 50 [label="Exit when"]; - } - 51 [label="Exit function test_2" style="filled" fillcolor=red]; - } - + 25 -> {26}; 26 -> {27}; 27 -> {28}; 28 -> {29}; - 29 -> {30 32}; - 30 -> {31}; + 29 -> {30}; + + subgraph cluster_7 { + color=red + 31 [label="Enter function test_2" style="filled" fillcolor=red]; + subgraph cluster_8 { + color=blue + 32 [label="Enter when"]; + subgraph cluster_9 { + color=blue + 33 [label="Enter when branch condition "]; + 34 [label="Access variable R|/s|"]; + 35 [label="Enter safe call"]; + 36 [label="Function call: R|/s|?.R|/check|()"]; + 37 [label="Exit safe call"]; + 38 [label="Const: Boolean(false)"]; + 39 [label="Operator =="]; + 40 [label="Exit when branch condition"]; + } + subgraph cluster_10 { + color=blue + 41 [label="Enter when branch condition else"]; + 42 [label="Exit when branch condition"]; + } + 43 [label="Enter when branch result"]; + subgraph cluster_11 { + color=blue + 44 [label="Enter block"]; + 45 [label="Access variable R|/s|"]; + 46 [label="Access variable #"]; + 47 [label="Exit block"]; + } + 48 [label="Exit when branch result"]; + 49 [label="Enter when branch result"]; + subgraph cluster_12 { + color=blue + 50 [label="Enter block"]; + 51 [label="Access variable R|/s|"]; + 52 [label="Access variable R|kotlin/String.length|"]; + 53 [label="Exit block"]; + } + 54 [label="Exit when branch result"]; + 55 [label="Exit when"]; + } + 56 [label="Exit function test_2" style="filled" fillcolor=red]; + } + 31 -> {32}; 32 -> {33}; 33 -> {34}; - 34 -> {35}; - 35 -> {44 36}; + 34 -> {35 37}; + 35 -> {36}; 36 -> {37}; 37 -> {38}; 38 -> {39}; 39 -> {40}; - 40 -> {41}; + 40 -> {49 41}; 41 -> {42}; 42 -> {43}; - 43 -> {50}; + 43 -> {44}; 44 -> {45}; 45 -> {46}; 46 -> {47}; 47 -> {48}; - 48 -> {49}; + 48 -> {55}; 49 -> {50}; 50 -> {51}; - - subgraph cluster_12 { - color=red - 52 [label="Enter function test_3" style="filled" fillcolor=red]; - subgraph cluster_13 { - color=blue - 53 [label="Enter when"]; - subgraph cluster_14 { - color=blue - 54 [label="Enter when branch condition "]; - 55 [label="Access variable R|/s|"]; - 56 [label="Enter safe call"]; - 57 [label="Function call: R|/s|?.R|kotlin/text/isNotEmpty|()"]; - 58 [label="Exit safe call"]; - 59 [label="Const: Boolean(true)"]; - 60 [label="Operator !="]; - 61 [label="Exit when branch condition"]; - } - subgraph cluster_15 { - color=blue - 62 [label="Enter when branch condition else"]; - 63 [label="Exit when branch condition"]; - } - 64 [label="Enter when branch result"]; - subgraph cluster_16 { - color=blue - 65 [label="Enter block"]; - 66 [label="Access variable R|/s|"]; - 67 [label="Access variable R|kotlin/String.length|"]; - 68 [label="Exit block"]; - } - 69 [label="Exit when branch result"]; - 70 [label="Enter when branch result"]; - subgraph cluster_17 { - color=blue - 71 [label="Enter block"]; - 72 [label="Access variable R|/s|"]; - 73 [label="Access variable #"]; - 74 [label="Exit block"]; - } - 75 [label="Exit when branch result"]; - 76 [label="Exit when"]; - } - 77 [label="Exit function test_3" style="filled" fillcolor=red]; - } - + 51 -> {52}; 52 -> {53}; 53 -> {54}; 54 -> {55}; - 55 -> {56 58}; - 56 -> {57}; + 55 -> {56}; + + subgraph cluster_13 { + color=red + 57 [label="Enter function test_3" style="filled" fillcolor=red]; + subgraph cluster_14 { + color=blue + 58 [label="Enter when"]; + subgraph cluster_15 { + color=blue + 59 [label="Enter when branch condition "]; + 60 [label="Access variable R|/s|"]; + 61 [label="Enter safe call"]; + 62 [label="Function call: R|/s|?.R|/check|()"]; + 63 [label="Exit safe call"]; + 64 [label="Const: Boolean(true)"]; + 65 [label="Operator !="]; + 66 [label="Exit when branch condition"]; + } + subgraph cluster_16 { + color=blue + 67 [label="Enter when branch condition else"]; + 68 [label="Exit when branch condition"]; + } + 69 [label="Enter when branch result"]; + subgraph cluster_17 { + color=blue + 70 [label="Enter block"]; + 71 [label="Access variable R|/s|"]; + 72 [label="Access variable R|kotlin/String.length|"]; + 73 [label="Exit block"]; + } + 74 [label="Exit when branch result"]; + 75 [label="Enter when branch result"]; + subgraph cluster_18 { + color=blue + 76 [label="Enter block"]; + 77 [label="Access variable R|/s|"]; + 78 [label="Access variable #"]; + 79 [label="Exit block"]; + } + 80 [label="Exit when branch result"]; + 81 [label="Exit when"]; + } + 82 [label="Exit function test_3" style="filled" fillcolor=red]; + } + 57 -> {58}; 58 -> {59}; 59 -> {60}; - 60 -> {61}; - 61 -> {70 62}; + 60 -> {61 63}; + 61 -> {62}; 62 -> {63}; 63 -> {64}; 64 -> {65}; 65 -> {66}; - 66 -> {67}; + 66 -> {75 67}; 67 -> {68}; 68 -> {69}; - 69 -> {76}; + 69 -> {70}; 70 -> {71}; 71 -> {72}; 72 -> {73}; 73 -> {74}; - 74 -> {75}; + 74 -> {81}; 75 -> {76}; 76 -> {77}; - - subgraph cluster_18 { - color=red - 78 [label="Enter function test_4" style="filled" fillcolor=red]; - subgraph cluster_19 { - color=blue - 79 [label="Enter when"]; - subgraph cluster_20 { - color=blue - 80 [label="Enter when branch condition "]; - 81 [label="Access variable R|/s|"]; - 82 [label="Enter safe call"]; - 83 [label="Function call: R|/s|?.R|kotlin/text/isNotEmpty|()"]; - 84 [label="Exit safe call"]; - 85 [label="Const: Boolean(false)"]; - 86 [label="Operator !="]; - 87 [label="Exit when branch condition"]; - } - subgraph cluster_21 { - color=blue - 88 [label="Enter when branch condition else"]; - 89 [label="Exit when branch condition"]; - } - 90 [label="Enter when branch result"]; - subgraph cluster_22 { - color=blue - 91 [label="Enter block"]; - 92 [label="Access variable R|/s|"]; - 93 [label="Access variable R|kotlin/String.length|"]; - 94 [label="Exit block"]; - } - 95 [label="Exit when branch result"]; - 96 [label="Enter when branch result"]; - subgraph cluster_23 { - color=blue - 97 [label="Enter block"]; - 98 [label="Access variable R|/s|"]; - 99 [label="Access variable #"]; - 100 [label="Exit block"]; - } - 101 [label="Exit when branch result"]; - 102 [label="Exit when"]; - } - 103 [label="Exit function test_4" style="filled" fillcolor=red]; - } - + 77 -> {78}; 78 -> {79}; 79 -> {80}; 80 -> {81}; - 81 -> {82 84}; - 82 -> {83}; + 81 -> {82}; + + subgraph cluster_19 { + color=red + 83 [label="Enter function test_4" style="filled" fillcolor=red]; + subgraph cluster_20 { + color=blue + 84 [label="Enter when"]; + subgraph cluster_21 { + color=blue + 85 [label="Enter when branch condition "]; + 86 [label="Access variable R|/s|"]; + 87 [label="Enter safe call"]; + 88 [label="Function call: R|/s|?.R|/check|()"]; + 89 [label="Exit safe call"]; + 90 [label="Const: Boolean(false)"]; + 91 [label="Operator !="]; + 92 [label="Exit when branch condition"]; + } + subgraph cluster_22 { + color=blue + 93 [label="Enter when branch condition else"]; + 94 [label="Exit when branch condition"]; + } + 95 [label="Enter when branch result"]; + subgraph cluster_23 { + color=blue + 96 [label="Enter block"]; + 97 [label="Access variable R|/s|"]; + 98 [label="Access variable R|kotlin/String.length|"]; + 99 [label="Exit block"]; + } + 100 [label="Exit when branch result"]; + 101 [label="Enter when branch result"]; + subgraph cluster_24 { + color=blue + 102 [label="Enter block"]; + 103 [label="Access variable R|/s|"]; + 104 [label="Access variable #"]; + 105 [label="Exit block"]; + } + 106 [label="Exit when branch result"]; + 107 [label="Exit when"]; + } + 108 [label="Exit function test_4" style="filled" fillcolor=red]; + } + 83 -> {84}; 84 -> {85}; 85 -> {86}; - 86 -> {87}; - 87 -> {96 88}; + 86 -> {87 89}; + 87 -> {88}; 88 -> {89}; 89 -> {90}; 90 -> {91}; 91 -> {92}; - 92 -> {93}; + 92 -> {101 93}; 93 -> {94}; 94 -> {95}; - 95 -> {102}; + 95 -> {96}; 96 -> {97}; 97 -> {98}; 98 -> {99}; 99 -> {100}; - 100 -> {101}; + 100 -> {107}; 101 -> {102}; 102 -> {103}; + 103 -> {104}; + 104 -> {105}; + 105 -> {106}; + 106 -> {107}; + 107 -> {108}; } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.kt b/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.kt index 247fbaadf63..741000c7541 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.kt @@ -1,5 +1,8 @@ +// !DUMP_CFG +fun String.check(): Boolean = true + fun test_1(s: String?) { - if (s?.isNotEmpty() == true) { + if (s?.check() == true) { s.length // Should be OK } else { s.length // Should be bad @@ -7,7 +10,7 @@ fun test_1(s: String?) { } fun test_2(s: String?) { - if (s?.isNotEmpty() == false) { + if (s?.check() == false) { s.length // Should be OK } else { s.length // Should be bad @@ -15,7 +18,7 @@ fun test_2(s: String?) { } fun test_3(s: String?) { - if (s?.isNotEmpty() != true) { + if (s?.check() != true) { s.length // Should be bad } else { s.length // Should be OK @@ -23,7 +26,7 @@ fun test_3(s: String?) { } fun test_4(s: String?) { - if (s?.isNotEmpty() != false) { + if (s?.check() != false) { s.length // Should be bad } else { s.length // Should be OK diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.txt b/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.txt index 3c85c6e1d67..74e883c7d4b 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.txt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.txt @@ -1,7 +1,10 @@ FILE: safeCallAndEqualityToBool.kt + public final fun R|kotlin/String|.check(): R|kotlin/Boolean| { + ^check Boolean(true) + } public final fun test_1(s: R|kotlin/String?|): R|kotlin/Unit| { when () { - ==(R|/s|?.R|kotlin/text/isNotEmpty|(), Boolean(true)) -> { + ==(R|/s|?.R|/check|(), Boolean(true)) -> { R|/s|.R|kotlin/String.length| } else -> { @@ -12,7 +15,7 @@ FILE: safeCallAndEqualityToBool.kt } public final fun test_2(s: R|kotlin/String?|): R|kotlin/Unit| { when () { - ==(R|/s|?.R|kotlin/text/isNotEmpty|(), Boolean(false)) -> { + ==(R|/s|?.R|/check|(), Boolean(false)) -> { R|/s|.R|kotlin/String.length| } else -> { @@ -23,7 +26,7 @@ FILE: safeCallAndEqualityToBool.kt } public final fun test_3(s: R|kotlin/String?|): R|kotlin/Unit| { when () { - !=(R|/s|?.R|kotlin/text/isNotEmpty|(), Boolean(true)) -> { + !=(R|/s|?.R|/check|(), Boolean(true)) -> { R|/s|.# } else -> { @@ -34,7 +37,7 @@ FILE: safeCallAndEqualityToBool.kt } public final fun test_4(s: R|kotlin/String?|): R|kotlin/Unit| { when () { - !=(R|/s|?.R|kotlin/text/isNotEmpty|(), Boolean(false)) -> { + !=(R|/s|?.R|/check|(), Boolean(false)) -> { R|/s|.# } else -> { diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCalls.kt b/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCalls.kt index 645412705bc..63ce62935cc 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCalls.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCalls.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG fun String.foo(b: Boolean): String = "" fun String.let(block: () -> Unit) {} diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/smartCastInInit.kt b/compiler/fir/resolve/testData/resolve/smartcasts/smartCastInInit.kt index 3e5962279ff..6c04bd27d89 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/smartCastInInit.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/smartCastInInit.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG interface I interface S : I { fun foo() diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/smartcastToNothing.kt b/compiler/fir/resolve/testData/resolve/smartcasts/smartcastToNothing.kt index 947639eacf6..8ed1de40206 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/smartcastToNothing.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/smartcastToNothing.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG fun getNothing(): Nothing = throw Exception() fun getNullableNothing(): Nothing? = null diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/stability/overridenOpenVal.kt b/compiler/fir/resolve/testData/resolve/smartcasts/stability/overridenOpenVal.kt index eef6f8a1aac..8742262e919 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/stability/overridenOpenVal.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/stability/overridenOpenVal.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG open class A(open val x: Any) class B(x: Any) : A(x) { diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/variables/delayedAssignment.kt b/compiler/fir/resolve/testData/resolve/smartcasts/variables/delayedAssignment.kt index 9487454844b..6bf18a7dd07 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/variables/delayedAssignment.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/variables/delayedAssignment.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG class A { fun foo() {} } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/variables/smartcastAfterReassignment.kt b/compiler/fir/resolve/testData/resolve/smartcasts/variables/smartcastAfterReassignment.kt index 4c2866f5e1a..b24f2f6b05d 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/variables/smartcastAfterReassignment.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/variables/smartcastAfterReassignment.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG fun test_1() { var x: Any = 1 x = "" diff --git a/compiler/fir/resolve/testData/resolveWithStdlib/contracts/callsInPlace.kt b/compiler/fir/resolve/testData/resolveWithStdlib/contracts/callsInPlace.kt index 03605c55595..449dc2b654d 100644 --- a/compiler/fir/resolve/testData/resolveWithStdlib/contracts/callsInPlace.kt +++ b/compiler/fir/resolve/testData/resolveWithStdlib/contracts/callsInPlace.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG fun test() { val x: Int run { diff --git a/compiler/fir/resolve/testData/resolveWithStdlib/contracts/conditionalEffects.kt b/compiler/fir/resolve/testData/resolveWithStdlib/contracts/conditionalEffects.kt index 370dea091a8..70adb821e9a 100644 --- a/compiler/fir/resolve/testData/resolveWithStdlib/contracts/conditionalEffects.kt +++ b/compiler/fir/resolve/testData/resolveWithStdlib/contracts/conditionalEffects.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG fun test_1(x: Any) { require(x is Int) x.inc() diff --git a/compiler/fir/resolve/testData/resolveWithStdlib/smartcasts/tryWithLambdaInside.kt b/compiler/fir/resolve/testData/resolveWithStdlib/smartcasts/tryWithLambdaInside.kt index 8b9f460b4f4..ef3a8f97ccf 100644 --- a/compiler/fir/resolve/testData/resolveWithStdlib/smartcasts/tryWithLambdaInside.kt +++ b/compiler/fir/resolve/testData/resolveWithStdlib/smartcasts/tryWithLambdaInside.kt @@ -1,3 +1,4 @@ +// !DUMP_CFG // FULL_JDK fun List.notInPlaceFilter(block: (T) -> Boolean): List = this diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/AbstractFirCfgBuildingWithStdlibTest.kt b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/AbstractFirCfgBuildingWithStdlibTest.kt deleted file mode 100644 index fe4bcada16f..00000000000 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/AbstractFirCfgBuildingWithStdlibTest.kt +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.fir - -import org.jetbrains.kotlin.test.ConfigurationKind - -abstract class AbstractFirDiagnosticsWithCfgAndStdlibTest : AbstractFirDiagnosticsWithCfgTest() { - override fun getConfigurationKind(): ConfigurationKind { - return ConfigurationKind.ALL - } -} \ No newline at end of file diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/AbstractFirDiagnosticTest.kt b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/AbstractFirDiagnosticTest.kt index a2f6ba4dfca..50464c32d1a 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/AbstractFirDiagnosticTest.kt +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/AbstractFirDiagnosticTest.kt @@ -5,14 +5,49 @@ package org.jetbrains.kotlin.fir +import junit.framework.TestCase import org.jetbrains.kotlin.fir.declarations.FirFile +import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference +import org.jetbrains.kotlin.fir.resolve.dfa.FirControlFlowGraphReferenceImpl +import org.jetbrains.kotlin.fir.resolve.dfa.cfg.CFGNode +import org.jetbrains.kotlin.fir.resolve.dfa.cfg.ControlFlowGraph +import org.jetbrains.kotlin.fir.resolve.dfa.cfg.EdgeKind +import org.jetbrains.kotlin.fir.resolve.dfa.cfg.FirControlFlowGraphRenderVisitor import org.jetbrains.kotlin.fir.resolve.diagnostics.collectors.AbstractDiagnosticCollector import org.jetbrains.kotlin.fir.resolve.diagnostics.collectors.FirDiagnosticsCollector import org.jetbrains.kotlin.fir.resolve.transformers.FirTotalResolveTransformer +import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid import org.jetbrains.kotlin.test.KotlinTestUtils +import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase import java.io.File +/* + * For comfort viewing dumps of control flow graph you can setup external tool in IDEA that opens .dot files + * + * Example of config for `xdot` viewer: + * + * File -> Settings -> External tools -> Add + * + * Name: XDot + * Program: xdot + * Arguments: $FileNameWithoutExtension$.dot + * Working directory: $FileDir$ + * Disable "Open console for tool output" + * + * After that you can run action `XDot` in editor with source of test (or with cfg dump) + * and it will opens xdot with dump for that test + */ abstract class AbstractFirDiagnosticsTest : AbstractFirBaseDiagnosticsTest() { + companion object { + val DUMP_CFG_DIRECTIVE = "DUMP_CFG" + + val TestFile.withDumpCfgDirective: Boolean + get() = DUMP_CFG_DIRECTIVE in directives + + val File.cfgDumpFile: File + get() = File(absolutePath.replace(".kt", ".dot")) + } + override fun runAnalysis(testDataFile: File, testFiles: List, firFilesPerSession: Map>) { for ((_, firFiles) in firFilesPerSession) { doFirResolveTestBench( @@ -24,6 +59,13 @@ abstract class AbstractFirDiagnosticsTest : AbstractFirBaseDiagnosticsTest() { val allFirFiles = firFilesPerSession.values.flatten() checkDiagnostics(testDataFile, testFiles, allFirFiles) checkFir(testDataFile, allFirFiles) + + if (testFiles.any { it.withDumpCfgDirective }) { + checkCfg(testDataFile, allFirFiles) + checkCfgEdgeConsistency(allFirFiles) + } else { + checkCfgDumpNotExists(testDataFile) + } } fun checkFir(testDataFile: File, firFiles: List) { @@ -53,4 +95,63 @@ abstract class AbstractFirDiagnosticsTest : AbstractFirBaseDiagnosticsTest() { protected fun createCollector(): AbstractDiagnosticCollector { return FirDiagnosticsCollector.create() } + + private fun checkCfg(testDataFile: File, firFiles: List) { + val builder = StringBuilder() + + firFiles.first().accept(FirControlFlowGraphRenderVisitor(builder), null) + + val dotCfgDump = builder.toString() + KotlinTestUtils.assertEqualsToFile(testDataFile.cfgDumpFile, dotCfgDump) + } + + private fun checkCfgEdgeConsistency(firFiles: List) { + firFiles.forEach { it.accept(CfgConsistencyChecker) } + } + + private object CfgConsistencyChecker : FirVisitorVoid() { + override fun visitElement(element: FirElement) { + element.acceptChildren(this) + } + + override fun visitControlFlowGraphReference(controlFlowGraphReference: FirControlFlowGraphReference) { + val graph = (controlFlowGraphReference as? FirControlFlowGraphReferenceImpl)?.controlFlowGraph ?: return + checkConsistency(graph) + } + + private fun checkConsistency(graph: ControlFlowGraph) { + for (node in graph.nodes) { + for (to in node.followingNodes) { + checkEdge(node, to) + } + for (from in node.previousNodes) { + checkEdge(from, node) + } + TestCase.assertTrue(node.followingNodes.isNotEmpty() || node.previousNodes.isNotEmpty()) + } + } + + private fun checkEdge(from: CFGNode<*>, to: CFGNode<*>) { + KtUsefulTestCase.assertContainsElements(from.followingNodes, to) + KtUsefulTestCase.assertContainsElements(to.previousNodes, from) + val fromKind = from.outgoingEdges.getValue(to) + val toKind = to.incomingEdges.getValue(from) + TestCase.assertEquals(fromKind, toKind) + if (from.isDead || to.isDead) { + KtUsefulTestCase.assertContainsElements(listOf(EdgeKind.Dead, EdgeKind.Cfg), toKind) + } + } + } + + private fun checkCfgDumpNotExists(testDataFile: File) { + val cfgDumpFile = testDataFile.cfgDumpFile + if (cfgDumpFile.exists()) { + val message = """ + Directive `!$DUMP_CFG_DIRECTIVE` is missing, but file with cfg dump is present. + Please remove ${cfgDumpFile.path} or add `!$DUMP_CFG_DIRECTIVE` to test + """.trimIndent() + kotlin.test.fail(message) + } + + } } \ No newline at end of file diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/AbstractFirDiagnosticsWithCfgTest.kt b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/AbstractFirDiagnosticsWithCfgTest.kt deleted file mode 100644 index 7642cbf440b..00000000000 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/AbstractFirDiagnosticsWithCfgTest.kt +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.fir - -import junit.framework.TestCase -import org.jetbrains.kotlin.fir.declarations.FirFile -import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference -import org.jetbrains.kotlin.fir.resolve.dfa.FirControlFlowGraphReferenceImpl -import org.jetbrains.kotlin.fir.resolve.dfa.cfg.CFGNode -import org.jetbrains.kotlin.fir.resolve.dfa.cfg.ControlFlowGraph -import org.jetbrains.kotlin.fir.resolve.dfa.cfg.EdgeKind -import org.jetbrains.kotlin.fir.resolve.dfa.cfg.FirControlFlowGraphRenderVisitor -import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid -import org.jetbrains.kotlin.test.ConfigurationKind -import org.jetbrains.kotlin.test.KotlinTestUtils -import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase -import java.io.File - - -/* - * For comfort viewing dumps of control flow graph you can setup external tool in IDEA that opens .dot files - * - * Example of config for `xdot` viewer: - * - * File -> Settings -> External tools -> Add - * - * Name: XDot - * Program: xdot - * Arguments: $FileNameWithoutExtension$.dot - * Working directory: $FileDir$ - * Disable "Open console for tool output" - * - * After that you can run action `XDot` in editor with source of test (or with cfg dump) - * and it will opens xdot with dump for that test - */ -abstract class AbstractFirDiagnosticsWithCfgTest : AbstractFirDiagnosticsTest() { - override fun getConfigurationKind(): ConfigurationKind { - return ConfigurationKind.ALL - } - - override fun runAnalysis(testDataFile: File, testFiles: List, firFilesPerSession: Map>) { - super.runAnalysis(testDataFile, testFiles, firFilesPerSession) - val allFirFiles = firFilesPerSession.values.flatten() - checkCfg(testDataFile, allFirFiles) - checkCfgEdgeConsistency(allFirFiles) - } - - private fun checkCfg(testDataFile: File, firFiles: List) { - val builder = StringBuilder() - - firFiles.first().accept(FirControlFlowGraphRenderVisitor(builder), null) - - val dotCfgDump = builder.toString() - val dotExpectedPath = testDataFile.absolutePath.replace(".kt", ".dot") - KotlinTestUtils.assertEqualsToFile(File(dotExpectedPath), dotCfgDump) - } - - private fun checkCfgEdgeConsistency(firFiles: List) { - firFiles.forEach { it.accept(CfgConsistencyChecker) } - } - - private object CfgConsistencyChecker : FirVisitorVoid() { - override fun visitElement(element: FirElement) { - element.acceptChildren(this) - } - - override fun visitControlFlowGraphReference(controlFlowGraphReference: FirControlFlowGraphReference) { - val graph = (controlFlowGraphReference as? FirControlFlowGraphReferenceImpl)?.controlFlowGraph ?: return - checkConsistency(graph) - } - - private fun checkConsistency(graph: ControlFlowGraph) { - for (node in graph.nodes) { - for (to in node.followingNodes) { - checkEdge(node, to) - } - for (from in node.previousNodes) { - checkEdge(from, node) - } - TestCase.assertTrue(node.followingNodes.isNotEmpty() || node.previousNodes.isNotEmpty()) - } - } - - private fun checkEdge(from: CFGNode<*>, to: CFGNode<*>) { - KtUsefulTestCase.assertContainsElements(from.followingNodes, to) - KtUsefulTestCase.assertContainsElements(to.previousNodes, from) - val fromKind = from.outgoingEdges.getValue(to) - val toKind = to.incomingEdges.getValue(from) - TestCase.assertEquals(fromKind, toKind) - if (from.isDead || to.isDead) { - KtUsefulTestCase.assertContainsElements(listOf(EdgeKind.Dead, EdgeKind.Cfg), toKind) - } - } - } -} \ No newline at end of file diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java index 41d4ad7c38e..f8efa09117b 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -25,7 +25,7 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { } public void testAllFilesPresentInResolve() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve"), Pattern.compile("^([^.]+)\\.kt$"), null, true, "stdlib", "cfg", "smartcasts"); + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } @TestMetadata("asImports.kt") @@ -454,6 +454,99 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { } } + @TestMetadata("compiler/fir/resolve/testData/resolve/cfg") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Cfg extends AbstractFirDiagnosticsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInCfg() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/cfg"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("binaryOperations.kt") + public void testBinaryOperations() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/binaryOperations.kt"); + } + + @TestMetadata("booleanOperatorsWithConsts.kt") + public void testBooleanOperatorsWithConsts() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/booleanOperatorsWithConsts.kt"); + } + + @TestMetadata("complex.kt") + public void testComplex() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/complex.kt"); + } + + @TestMetadata("emptyWhen.kt") + public void testEmptyWhen() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/emptyWhen.kt"); + } + + @TestMetadata("initBlock.kt") + public void testInitBlock() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/initBlock.kt"); + } + + @TestMetadata("initBlockAndInPlaceLambda.kt") + public void testInitBlockAndInPlaceLambda() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/initBlockAndInPlaceLambda.kt"); + } + + @TestMetadata("jumps.kt") + public void testJumps() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/jumps.kt"); + } + + @TestMetadata("lambdas.kt") + public void testLambdas() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/lambdas.kt"); + } + + @TestMetadata("loops.kt") + public void testLoops() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/loops.kt"); + } + + @TestMetadata("postponedLambdas.kt") + public void testPostponedLambdas() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/postponedLambdas.kt"); + } + + @TestMetadata("propertiesAndInitBlocks.kt") + public void testPropertiesAndInitBlocks() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.kt"); + } + + @TestMetadata("returnValuesFromLambda.kt") + public void testReturnValuesFromLambda() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/returnValuesFromLambda.kt"); + } + + @TestMetadata("safeCalls.kt") + public void testSafeCalls() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/safeCalls.kt"); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/simple.kt"); + } + + @TestMetadata("tryCatch.kt") + public void testTryCatch() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/tryCatch.kt"); + } + + @TestMetadata("when.kt") + public void testWhen() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/when.kt"); + } + } + @TestMetadata("compiler/fir/resolve/testData/resolve/diagnostics") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -1305,4 +1398,297 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { runTest("compiler/fir/resolve/testData/resolve/samConversions/simple.kt"); } } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Smartcasts extends AbstractFirDiagnosticsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSmartcasts() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("bangbang.kt") + public void testBangbang() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/bangbang.kt"); + } + + @TestMetadata("casts.kt") + public void testCasts() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/casts.kt"); + } + + @TestMetadata("equalsAndIdentity.kt") + public void testEqualsAndIdentity() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/equalsAndIdentity.kt"); + } + + @TestMetadata("multipleCasts.kt") + public void testMultipleCasts() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/multipleCasts.kt"); + } + + @TestMetadata("nullability.kt") + public void testNullability() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/nullability.kt"); + } + + @TestMetadata("smartCastInInit.kt") + public void testSmartCastInInit() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/smartCastInInit.kt"); + } + + @TestMetadata("smartcastToNothing.kt") + public void testSmartcastToNothing() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/smartcastToNothing.kt"); + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/booleans") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Booleans extends AbstractFirDiagnosticsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInBooleans() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/booleans"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("booleanOperators.kt") + public void testBooleanOperators() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/booleans/booleanOperators.kt"); + } + + @TestMetadata("equalsToBoolean.kt") + public void testEqualsToBoolean() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/booleans/equalsToBoolean.kt"); + } + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class BoundSmartcasts extends AbstractFirDiagnosticsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInBoundSmartcasts() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("boundSmartcasts.kt") + public void testBoundSmartcasts() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.kt"); + } + + @TestMetadata("boundSmartcastsInBranches.kt") + public void testBoundSmartcastsInBranches() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastsInBranches.kt"); + } + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/controlStructures") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ControlStructures extends AbstractFirDiagnosticsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInControlStructures() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/controlStructures"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("elvis.kt") + public void testElvis() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/elvis.kt"); + } + + @TestMetadata("returns.kt") + public void testReturns() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/returns.kt"); + } + + @TestMetadata("simpleIf.kt") + public void testSimpleIf() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/simpleIf.kt"); + } + + @TestMetadata("smartcastFromArgument.kt") + public void testSmartcastFromArgument() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/smartcastFromArgument.kt"); + } + + @TestMetadata("when.kt") + public void testWhen() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/when.kt"); + } + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/lambdas") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Lambdas extends AbstractFirDiagnosticsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInLambdas() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/lambdas"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("inPlaceLambdas.kt") + public void testInPlaceLambdas() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/lambdas/inPlaceLambdas.kt"); + } + + @TestMetadata("smartcastOnLambda.kt") + public void testSmartcastOnLambda() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/lambdas/smartcastOnLambda.kt"); + } + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/loops") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Loops extends AbstractFirDiagnosticsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInLoops() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/loops"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("dataFlowInfoFromWhileCondition.kt") + public void testDataFlowInfoFromWhileCondition() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/loops/dataFlowInfoFromWhileCondition.kt"); + } + + @TestMetadata("endlessLoops.kt") + public void testEndlessLoops() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/loops/endlessLoops.kt"); + } + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/problems") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Problems extends AbstractFirDiagnosticsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInProblems() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/problems"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("smartcastOnBangBang.kt") + public void testSmartcastOnBangBang() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/problems/smartcastOnBangBang.kt"); + } + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/receivers") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Receivers extends AbstractFirDiagnosticsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInReceivers() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/receivers"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("implicitReceiverAsWhenSubject.kt") + public void testImplicitReceiverAsWhenSubject() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceiverAsWhenSubject.kt"); + } + + @TestMetadata("implicitReceivers.kt") + public void testImplicitReceivers() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceivers.kt"); + } + + @TestMetadata("thisOfExtensionProperty.kt") + public void testThisOfExtensionProperty() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/receivers/thisOfExtensionProperty.kt"); + } + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/safeCalls") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SafeCalls extends AbstractFirDiagnosticsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSafeCalls() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/safeCalls"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("assignSafeCall.kt") + public void testAssignSafeCall() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/assignSafeCall.kt"); + } + + @TestMetadata("safeCallAndEqualityToBool.kt") + public void testSafeCallAndEqualityToBool() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.kt"); + } + + @TestMetadata("safeCalls.kt") + public void testSafeCalls() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCalls.kt"); + } + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/stability") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Stability extends AbstractFirDiagnosticsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInStability() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/stability"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("overridenOpenVal.kt") + public void testOverridenOpenVal() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/stability/overridenOpenVal.kt"); + } + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/variables") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Variables extends AbstractFirDiagnosticsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInVariables() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/variables"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("delayedAssignment.kt") + public void testDelayedAssignment() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/variables/delayedAssignment.kt"); + } + + @TestMetadata("smartcastAfterReassignment.kt") + public void testSmartcastAfterReassignment() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/variables/smartcastAfterReassignment.kt"); + } + } + } } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithCfgAndStdlibTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithCfgAndStdlibTestGenerated.java deleted file mode 100644 index fab7f99e0c5..00000000000 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithCfgAndStdlibTestGenerated.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.fir; - -import com.intellij.testFramework.TestDataPath; -import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; -import org.jetbrains.kotlin.test.KotlinTestUtils; -import org.jetbrains.kotlin.test.TestMetadata; -import org.junit.runner.RunWith; - -import java.io.File; -import java.util.regex.Pattern; - -/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ -@SuppressWarnings("all") -@RunWith(JUnit3RunnerWithInners.class) -public class FirDiagnosticsWithCfgAndStdlibTestGenerated extends AbstractFirDiagnosticsWithCfgAndStdlibTest { - @TestMetadata("compiler/fir/resolve/testData/resolveWithStdlib/contracts") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Contracts extends AbstractFirDiagnosticsWithCfgAndStdlibTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInContracts() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolveWithStdlib/contracts"), Pattern.compile("^([^.]+)\\.kt$"), null, true); - } - - @TestMetadata("callsInPlace.kt") - public void testCallsInPlace() throws Exception { - runTest("compiler/fir/resolve/testData/resolveWithStdlib/contracts/callsInPlace.kt"); - } - - @TestMetadata("conditionalEffects.kt") - public void testConditionalEffects() throws Exception { - runTest("compiler/fir/resolve/testData/resolveWithStdlib/contracts/conditionalEffects.kt"); - } - } - - @TestMetadata("compiler/fir/resolve/testData/resolveWithStdlib/smartcasts") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Smartcasts extends AbstractFirDiagnosticsWithCfgAndStdlibTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInSmartcasts() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolveWithStdlib/smartcasts"), Pattern.compile("^([^.]+)\\.kt$"), null, true); - } - - @TestMetadata("tryWithLambdaInside.kt") - public void testTryWithLambdaInside() throws Exception { - runTest("compiler/fir/resolve/testData/resolveWithStdlib/smartcasts/tryWithLambdaInside.kt"); - } - } -} diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithCfgTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithCfgTestGenerated.java deleted file mode 100644 index bc8c11194ed..00000000000 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithCfgTestGenerated.java +++ /dev/null @@ -1,406 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.fir; - -import com.intellij.testFramework.TestDataPath; -import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; -import org.jetbrains.kotlin.test.KotlinTestUtils; -import org.jetbrains.kotlin.test.TestMetadata; -import org.junit.runner.RunWith; - -import java.io.File; -import java.util.regex.Pattern; - -/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ -@SuppressWarnings("all") -@RunWith(JUnit3RunnerWithInners.class) -public class FirDiagnosticsWithCfgTestGenerated extends AbstractFirDiagnosticsWithCfgTest { - @TestMetadata("compiler/fir/resolve/testData/resolve/cfg") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Cfg extends AbstractFirDiagnosticsWithCfgTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInCfg() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/cfg"), Pattern.compile("^([^.]+)\\.kt$"), null, true); - } - - @TestMetadata("binaryOperations.kt") - public void testBinaryOperations() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/cfg/binaryOperations.kt"); - } - - @TestMetadata("booleanOperatorsWithConsts.kt") - public void testBooleanOperatorsWithConsts() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/cfg/booleanOperatorsWithConsts.kt"); - } - - @TestMetadata("complex.kt") - public void testComplex() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/cfg/complex.kt"); - } - - @TestMetadata("emptyWhen.kt") - public void testEmptyWhen() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/cfg/emptyWhen.kt"); - } - - @TestMetadata("initBlock.kt") - public void testInitBlock() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/cfg/initBlock.kt"); - } - - @TestMetadata("initBlockAndInPlaceLambda.kt") - public void testInitBlockAndInPlaceLambda() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/cfg/initBlockAndInPlaceLambda.kt"); - } - - @TestMetadata("jumps.kt") - public void testJumps() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/cfg/jumps.kt"); - } - - @TestMetadata("lambdas.kt") - public void testLambdas() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/cfg/lambdas.kt"); - } - - @TestMetadata("loops.kt") - public void testLoops() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/cfg/loops.kt"); - } - - @TestMetadata("postponedLambdas.kt") - public void testPostponedLambdas() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/cfg/postponedLambdas.kt"); - } - - @TestMetadata("propertiesAndInitBlocks.kt") - public void testPropertiesAndInitBlocks() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.kt"); - } - - @TestMetadata("returnValuesFromLambda.kt") - public void testReturnValuesFromLambda() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/cfg/returnValuesFromLambda.kt"); - } - - @TestMetadata("safeCalls.kt") - public void testSafeCalls() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/cfg/safeCalls.kt"); - } - - @TestMetadata("simple.kt") - public void testSimple() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/cfg/simple.kt"); - } - - @TestMetadata("tryCatch.kt") - public void testTryCatch() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/cfg/tryCatch.kt"); - } - - @TestMetadata("when.kt") - public void testWhen() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/cfg/when.kt"); - } - } - - @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Smartcasts extends AbstractFirDiagnosticsWithCfgTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInSmartcasts() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts"), Pattern.compile("^([^.]+)\\.kt$"), null, true); - } - - @TestMetadata("bangbang.kt") - public void testBangbang() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/bangbang.kt"); - } - - @TestMetadata("casts.kt") - public void testCasts() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/casts.kt"); - } - - @TestMetadata("equalsAndIdentity.kt") - public void testEqualsAndIdentity() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/equalsAndIdentity.kt"); - } - - @TestMetadata("multipleCasts.kt") - public void testMultipleCasts() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/multipleCasts.kt"); - } - - @TestMetadata("nullability.kt") - public void testNullability() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/nullability.kt"); - } - - @TestMetadata("smartCastInInit.kt") - public void testSmartCastInInit() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/smartCastInInit.kt"); - } - - @TestMetadata("smartcastToNothing.kt") - public void testSmartcastToNothing() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/smartcastToNothing.kt"); - } - - @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/booleans") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Booleans extends AbstractFirDiagnosticsWithCfgTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInBooleans() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/booleans"), Pattern.compile("^([^.]+)\\.kt$"), null, true); - } - - @TestMetadata("booleanOperators.kt") - public void testBooleanOperators() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/booleans/booleanOperators.kt"); - } - - @TestMetadata("equalsToBoolean.kt") - public void testEqualsToBoolean() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/booleans/equalsToBoolean.kt"); - } - } - - @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class BoundSmartcasts extends AbstractFirDiagnosticsWithCfgTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInBoundSmartcasts() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts"), Pattern.compile("^([^.]+)\\.kt$"), null, true); - } - - @TestMetadata("boundSmartcasts.kt") - public void testBoundSmartcasts() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.kt"); - } - - @TestMetadata("boundSmartcastsInBranches.kt") - public void testBoundSmartcastsInBranches() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastsInBranches.kt"); - } - } - - @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/controlStructures") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ControlStructures extends AbstractFirDiagnosticsWithCfgTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInControlStructures() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/controlStructures"), Pattern.compile("^([^.]+)\\.kt$"), null, true); - } - - @TestMetadata("elvis.kt") - public void testElvis() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/elvis.kt"); - } - - @TestMetadata("returns.kt") - public void testReturns() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/returns.kt"); - } - - @TestMetadata("simpleIf.kt") - public void testSimpleIf() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/simpleIf.kt"); - } - - @TestMetadata("smartcastFromArgument.kt") - public void testSmartcastFromArgument() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/smartcastFromArgument.kt"); - } - - @TestMetadata("when.kt") - public void testWhen() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/when.kt"); - } - } - - @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/lambdas") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Lambdas extends AbstractFirDiagnosticsWithCfgTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInLambdas() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/lambdas"), Pattern.compile("^([^.]+)\\.kt$"), null, true); - } - - @TestMetadata("inPlaceLambdas.kt") - public void testInPlaceLambdas() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/lambdas/inPlaceLambdas.kt"); - } - - @TestMetadata("smartcastOnLambda.kt") - public void testSmartcastOnLambda() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/lambdas/smartcastOnLambda.kt"); - } - } - - @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/loops") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Loops extends AbstractFirDiagnosticsWithCfgTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInLoops() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/loops"), Pattern.compile("^([^.]+)\\.kt$"), null, true); - } - - @TestMetadata("dataFlowInfoFromWhileCondition.kt") - public void testDataFlowInfoFromWhileCondition() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/loops/dataFlowInfoFromWhileCondition.kt"); - } - - @TestMetadata("endlessLoops.kt") - public void testEndlessLoops() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/loops/endlessLoops.kt"); - } - } - - @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/problems") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Problems extends AbstractFirDiagnosticsWithCfgTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInProblems() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/problems"), Pattern.compile("^([^.]+)\\.kt$"), null, true); - } - - @TestMetadata("smartcastOnBangBang.kt") - public void testSmartcastOnBangBang() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/problems/smartcastOnBangBang.kt"); - } - } - - @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/receivers") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Receivers extends AbstractFirDiagnosticsWithCfgTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInReceivers() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/receivers"), Pattern.compile("^([^.]+)\\.kt$"), null, true); - } - - @TestMetadata("implicitReceiverAsWhenSubject.kt") - public void testImplicitReceiverAsWhenSubject() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceiverAsWhenSubject.kt"); - } - - @TestMetadata("implicitReceivers.kt") - public void testImplicitReceivers() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceivers.kt"); - } - - @TestMetadata("thisOfExtensionProperty.kt") - public void testThisOfExtensionProperty() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/receivers/thisOfExtensionProperty.kt"); - } - } - - @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/safeCalls") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class SafeCalls extends AbstractFirDiagnosticsWithCfgTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInSafeCalls() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/safeCalls"), Pattern.compile("^([^.]+)\\.kt$"), null, true); - } - - @TestMetadata("assignSafeCall.kt") - public void testAssignSafeCall() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/assignSafeCall.kt"); - } - - @TestMetadata("safeCallAndEqualityToBool.kt") - public void testSafeCallAndEqualityToBool() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.kt"); - } - - @TestMetadata("safeCalls.kt") - public void testSafeCalls() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCalls.kt"); - } - } - - @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/stability") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Stability extends AbstractFirDiagnosticsWithCfgTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInStability() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/stability"), Pattern.compile("^([^.]+)\\.kt$"), null, true); - } - - @TestMetadata("overridenOpenVal.kt") - public void testOverridenOpenVal() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/stability/overridenOpenVal.kt"); - } - } - - @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/variables") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Variables extends AbstractFirDiagnosticsWithCfgTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInVariables() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/variables"), Pattern.compile("^([^.]+)\\.kt$"), null, true); - } - - @TestMetadata("delayedAssignment.kt") - public void testDelayedAssignment() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/variables/delayedAssignment.kt"); - } - - @TestMetadata("smartcastAfterReassignment.kt") - public void testSmartcastAfterReassignment() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/smartcasts/variables/smartcastAfterReassignment.kt"); - } - } - } -} diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java index ade75d50722..5b6892925c1 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java @@ -25,7 +25,7 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos } public void testAllFilesPresentInResolve() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve"), Pattern.compile("^([^.]+)\\.kt$"), null, true, "stdlib", "cfg", "smartcasts"); + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } @TestMetadata("asImports.kt") @@ -454,6 +454,99 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos } } + @TestMetadata("compiler/fir/resolve/testData/resolve/cfg") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Cfg extends AbstractFirDiagnosticsWithLightTreeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInCfg() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/cfg"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("binaryOperations.kt") + public void testBinaryOperations() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/binaryOperations.kt"); + } + + @TestMetadata("booleanOperatorsWithConsts.kt") + public void testBooleanOperatorsWithConsts() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/booleanOperatorsWithConsts.kt"); + } + + @TestMetadata("complex.kt") + public void testComplex() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/complex.kt"); + } + + @TestMetadata("emptyWhen.kt") + public void testEmptyWhen() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/emptyWhen.kt"); + } + + @TestMetadata("initBlock.kt") + public void testInitBlock() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/initBlock.kt"); + } + + @TestMetadata("initBlockAndInPlaceLambda.kt") + public void testInitBlockAndInPlaceLambda() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/initBlockAndInPlaceLambda.kt"); + } + + @TestMetadata("jumps.kt") + public void testJumps() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/jumps.kt"); + } + + @TestMetadata("lambdas.kt") + public void testLambdas() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/lambdas.kt"); + } + + @TestMetadata("loops.kt") + public void testLoops() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/loops.kt"); + } + + @TestMetadata("postponedLambdas.kt") + public void testPostponedLambdas() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/postponedLambdas.kt"); + } + + @TestMetadata("propertiesAndInitBlocks.kt") + public void testPropertiesAndInitBlocks() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.kt"); + } + + @TestMetadata("returnValuesFromLambda.kt") + public void testReturnValuesFromLambda() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/returnValuesFromLambda.kt"); + } + + @TestMetadata("safeCalls.kt") + public void testSafeCalls() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/safeCalls.kt"); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/simple.kt"); + } + + @TestMetadata("tryCatch.kt") + public void testTryCatch() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/tryCatch.kt"); + } + + @TestMetadata("when.kt") + public void testWhen() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/cfg/when.kt"); + } + } + @TestMetadata("compiler/fir/resolve/testData/resolve/diagnostics") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -1305,4 +1398,297 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/resolve/testData/resolve/samConversions/simple.kt"); } } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Smartcasts extends AbstractFirDiagnosticsWithLightTreeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSmartcasts() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("bangbang.kt") + public void testBangbang() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/bangbang.kt"); + } + + @TestMetadata("casts.kt") + public void testCasts() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/casts.kt"); + } + + @TestMetadata("equalsAndIdentity.kt") + public void testEqualsAndIdentity() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/equalsAndIdentity.kt"); + } + + @TestMetadata("multipleCasts.kt") + public void testMultipleCasts() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/multipleCasts.kt"); + } + + @TestMetadata("nullability.kt") + public void testNullability() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/nullability.kt"); + } + + @TestMetadata("smartCastInInit.kt") + public void testSmartCastInInit() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/smartCastInInit.kt"); + } + + @TestMetadata("smartcastToNothing.kt") + public void testSmartcastToNothing() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/smartcastToNothing.kt"); + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/booleans") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Booleans extends AbstractFirDiagnosticsWithLightTreeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInBooleans() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/booleans"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("booleanOperators.kt") + public void testBooleanOperators() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/booleans/booleanOperators.kt"); + } + + @TestMetadata("equalsToBoolean.kt") + public void testEqualsToBoolean() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/booleans/equalsToBoolean.kt"); + } + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class BoundSmartcasts extends AbstractFirDiagnosticsWithLightTreeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInBoundSmartcasts() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("boundSmartcasts.kt") + public void testBoundSmartcasts() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.kt"); + } + + @TestMetadata("boundSmartcastsInBranches.kt") + public void testBoundSmartcastsInBranches() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastsInBranches.kt"); + } + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/controlStructures") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ControlStructures extends AbstractFirDiagnosticsWithLightTreeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInControlStructures() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/controlStructures"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("elvis.kt") + public void testElvis() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/elvis.kt"); + } + + @TestMetadata("returns.kt") + public void testReturns() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/returns.kt"); + } + + @TestMetadata("simpleIf.kt") + public void testSimpleIf() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/simpleIf.kt"); + } + + @TestMetadata("smartcastFromArgument.kt") + public void testSmartcastFromArgument() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/smartcastFromArgument.kt"); + } + + @TestMetadata("when.kt") + public void testWhen() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/when.kt"); + } + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/lambdas") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Lambdas extends AbstractFirDiagnosticsWithLightTreeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInLambdas() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/lambdas"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("inPlaceLambdas.kt") + public void testInPlaceLambdas() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/lambdas/inPlaceLambdas.kt"); + } + + @TestMetadata("smartcastOnLambda.kt") + public void testSmartcastOnLambda() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/lambdas/smartcastOnLambda.kt"); + } + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/loops") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Loops extends AbstractFirDiagnosticsWithLightTreeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInLoops() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/loops"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("dataFlowInfoFromWhileCondition.kt") + public void testDataFlowInfoFromWhileCondition() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/loops/dataFlowInfoFromWhileCondition.kt"); + } + + @TestMetadata("endlessLoops.kt") + public void testEndlessLoops() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/loops/endlessLoops.kt"); + } + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/problems") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Problems extends AbstractFirDiagnosticsWithLightTreeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInProblems() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/problems"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("smartcastOnBangBang.kt") + public void testSmartcastOnBangBang() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/problems/smartcastOnBangBang.kt"); + } + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/receivers") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Receivers extends AbstractFirDiagnosticsWithLightTreeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInReceivers() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/receivers"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("implicitReceiverAsWhenSubject.kt") + public void testImplicitReceiverAsWhenSubject() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceiverAsWhenSubject.kt"); + } + + @TestMetadata("implicitReceivers.kt") + public void testImplicitReceivers() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceivers.kt"); + } + + @TestMetadata("thisOfExtensionProperty.kt") + public void testThisOfExtensionProperty() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/receivers/thisOfExtensionProperty.kt"); + } + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/safeCalls") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SafeCalls extends AbstractFirDiagnosticsWithLightTreeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSafeCalls() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/safeCalls"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("assignSafeCall.kt") + public void testAssignSafeCall() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/assignSafeCall.kt"); + } + + @TestMetadata("safeCallAndEqualityToBool.kt") + public void testSafeCallAndEqualityToBool() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.kt"); + } + + @TestMetadata("safeCalls.kt") + public void testSafeCalls() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCalls.kt"); + } + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/stability") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Stability extends AbstractFirDiagnosticsWithLightTreeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInStability() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/stability"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("overridenOpenVal.kt") + public void testOverridenOpenVal() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/stability/overridenOpenVal.kt"); + } + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/smartcasts/variables") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Variables extends AbstractFirDiagnosticsWithLightTreeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInVariables() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/smartcasts/variables"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("delayedAssignment.kt") + public void testDelayedAssignment() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/variables/delayedAssignment.kt"); + } + + @TestMetadata("smartcastAfterReassignment.kt") + public void testSmartcastAfterReassignment() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/variables/smartcastAfterReassignment.kt"); + } + } + } } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java index b1e6d842228..e3a93393d4e 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java @@ -30,7 +30,7 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic } public void testAllFilesPresentInResolveWithStdlib() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolveWithStdlib"), Pattern.compile("^([^.]+)\\.kt$"), null, true, "contracts", "smartcasts"); + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolveWithStdlib"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } @TestMetadata("anonymousInDelegate.kt") @@ -454,6 +454,29 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic } } + @TestMetadata("compiler/fir/resolve/testData/resolveWithStdlib/contracts") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Contracts extends AbstractFirDiagnosticsWithStdlibTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInContracts() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolveWithStdlib/contracts"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("callsInPlace.kt") + public void testCallsInPlace() throws Exception { + runTest("compiler/fir/resolve/testData/resolveWithStdlib/contracts/callsInPlace.kt"); + } + + @TestMetadata("conditionalEffects.kt") + public void testConditionalEffects() throws Exception { + runTest("compiler/fir/resolve/testData/resolveWithStdlib/contracts/conditionalEffects.kt"); + } + } + @TestMetadata("compiler/fir/resolve/testData/resolveWithStdlib/inference") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -667,4 +690,22 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic runTest("compiler/fir/resolve/testData/resolveWithStdlib/problems/weakHashMap.kt"); } } + + @TestMetadata("compiler/fir/resolve/testData/resolveWithStdlib/smartcasts") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Smartcasts extends AbstractFirDiagnosticsWithStdlibTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSmartcasts() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolveWithStdlib/smartcasts"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("tryWithLambdaInside.kt") + public void testTryWithLambdaInside() throws Exception { + runTest("compiler/fir/resolve/testData/resolveWithStdlib/smartcasts/tryWithLambdaInside.kt"); + } + } } diff --git a/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt b/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt index 67577443de4..b0bd2b474b8 100644 --- a/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt +++ b/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt @@ -547,27 +547,17 @@ fun main(args: Array) { testGroup("compiler/fir/resolve/tests", "compiler/fir/resolve/testData") { testClass { - model("resolve", pattern = KT_WITHOUT_DOTS_IN_NAME, excludeDirs = listOf("stdlib", "cfg", "smartcasts")) + model("resolve", pattern = KT_WITHOUT_DOTS_IN_NAME) } testClass { - model("resolve", pattern = KT_WITHOUT_DOTS_IN_NAME, excludeDirs = listOf("stdlib", "cfg", "smartcasts")) - } - - testClass { - model("resolve/cfg", pattern = KT_WITHOUT_DOTS_IN_NAME) - model("resolve/smartcasts", pattern = KT_WITHOUT_DOTS_IN_NAME) + model("resolve", pattern = KT_WITHOUT_DOTS_IN_NAME) } } testGroup("compiler/fir/resolve/tests", "compiler/fir/resolve/testData") { testClass { - model("resolveWithStdlib", pattern = KT_WITHOUT_DOTS_IN_NAME, excludeDirs = listOf("contracts", "smartcasts")) - } - - testClass { - model("resolveWithStdlib/contracts", pattern = KT_WITHOUT_DOTS_IN_NAME) - model("resolveWithStdlib/smartcasts", pattern = KT_WITHOUT_DOTS_IN_NAME) + model("resolveWithStdlib", pattern = KT_WITHOUT_DOTS_IN_NAME) } }