From a6984c5198634dc65551a585dcb1252131b7fcca Mon Sep 17 00:00:00 2001 From: Andrey Zinovyev Date: Thu, 8 Jul 2021 15:29:31 +0300 Subject: [PATCH] [FIR] Add NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY diagnostic --- .../resolve/arguments/lambdaInLambda.kt | 2 +- .../arguments/operatorsOverLiterals.kt | 6 +- .../resolve/cfg/flowFromInplaceLambda.dot | 544 +++++++++--------- .../inplaceLambdaInControlFlowExpressions.dot | 218 +++---- .../testData/resolve/constantValues.kt | 2 +- .../operators/plusAndPlusAssign.kt | 2 +- .../testData/resolve/functionTypes.kt | 2 +- .../resolve/problems/compilerPhase.kt | 6 +- .../properties/kotlinOverridesJavaComplex.kt | 2 +- .../resolve/smartcasts/smartcastToNothing.dot | 220 +++---- .../referenceToJavaStdlib.kt | 2 +- .../callableReferences/sam.kt | 2 +- .../callableReferences/simpleClassReceiver.kt | 2 +- .../simpleExpressionReceiver.kt | 2 +- .../callableReferences/simpleNoReceiver.kt | 2 +- .../delegates/delegateWithAnonymousObject.dot | 214 +++---- .../inference/plusAssignWithLambdaInRhs.dot | 168 +++--- .../diagnostics/FirDiagnosticsList.kt | 1 + .../diagnostics/model/DiagnosticData.kt | 1 + .../fir/analysis/diagnostics/FirErrors.kt | 2 + .../checkers/CommonDeclarationCheckers.kt | 3 +- .../declaration/FirFunctionReturnChecker.kt | 41 ++ .../declaration/FirPropertyAccessorChecker.kt | 1 + .../diagnostics/FirDefaultErrorMessages.kt | 3 + .../LightTreePositioningStrategies.kt | 23 + .../SourceElementPositioningStrategies.kt | 5 + .../dfa/cfg/ControlFlowGraphBuilder.kt | 3 +- ...rCallCompletionResultsWriterTransformer.kt | 8 +- .../tests/FunctionReturnTypes.fir.kt | 20 +- .../diagnostics/tests/OperatorChecks.fir.kt | 96 ++-- .../diagnostics/tests/TypeInference.fir.kt | 18 - .../diagnostics/tests/TypeInference.kt | 1 + .../ReturnFromFunctionInObject.fir.kt | 13 - .../ReturnFromFunctionInObject.kt | 1 + .../kt3444_ReturnFromLocalFunctions.fir.kt | 17 - .../kt3444_ReturnFromLocalFunctions.kt | 1 + .../definiteReturn/simpleClass.fir.kt | 4 +- .../definiteReturnInWhen.fir.kt | 2 +- .../tests/controlFlowAnalysis/kt3444.fir.kt | 13 - .../tests/controlFlowAnalysis/kt3444.kt | 1 + .../tests/controlFlowAnalysis/kt4405.fir.kt | 6 +- .../controlFlowAnalysis/localClasses.fir.kt | 6 +- .../tests/controlStructures/kt786.fir.kt | 2 +- .../missedTypeMismatch.fir.kt | 6 +- .../tests/generics/genericsInType.fir.kt | 2 +- .../SupertypeOfErrorType.fir.kt | 2 +- .../checkNothingIsSubtype.fir.kt | 4 +- .../incompleteAssignment.fir.kt | 6 +- .../incompleteCode/incompleteAssignment.kt | 2 + ...finitelyNotNullTypeInReturnPosition.fir.kt | 2 +- .../dependantOnVarianceNullable.fir.kt | 14 - .../inference/dependantOnVarianceNullable.kt | 1 + .../tests/inference/mapFunction.fir.kt | 4 +- .../mostSpecificAfterInference.fir.kt | 4 +- .../possibleCycleOnConstraints.fir.kt | 2 +- .../tests/inference/regressions/kt1029.fir.kt | 19 - .../tests/inference/regressions/kt1029.kt | 1 + .../tests/inference/regressions/kt1031.fir.kt | 22 - .../tests/inference/regressions/kt1031.kt | 1 + .../tests/inference/regressions/kt1127.fir.kt | 2 +- .../tests/inference/regressions/kt1145.fir.kt | 4 +- .../tests/inference/regressions/kt1410.fir.kt | 28 - .../tests/inference/regressions/kt1410.kt | 1 + .../tests/inference/regressions/kt1718.fir.kt | 4 +- .../tests/inference/regressions/kt2286.fir.kt | 2 +- .../tests/inference/regressions/kt2407.fir.kt | 6 +- .../tests/inference/regressions/kt2459.fir.kt | 10 - .../tests/inference/regressions/kt2459.kt | 1 + .../tests/inference/regressions/kt2842.fir.kt | 27 - .../tests/inference/regressions/kt2842.kt | 1 + .../tests/inference/regressions/kt2883.fir.kt | 2 +- .../tests/inference/regressions/kt3007.fir.kt | 43 -- .../tests/inference/regressions/kt3007.kt | 1 + .../tests/inference/regressions/kt3301.fir.kt | 20 - .../tests/inference/regressions/kt3301.kt | 1 + .../tests/inference/regressions/kt702.fir.kt | 2 +- .../tests/inference/regressions/kt943.fir.kt | 23 - .../tests/inference/regressions/kt943.kt | 1 + ...ubtypeForInvariantWithErrorGenerics.fir.kt | 12 - .../subtypeForInvariantWithErrorGenerics.kt | 1 + .../useBoundsToInferTypeParamsSimple.fir.kt | 2 +- .../diagnostics/tests/infos/SmartCasts.fir.kt | 2 +- .../tests/library/Collections.fir.kt | 2 +- .../tests/regressions/kt402.fir.kt | 8 - .../diagnostics/tests/regressions/kt402.kt | 1 + .../tests/regressions/kt442.fir.kt | 31 - .../diagnostics/tests/regressions/kt442.kt | 1 + .../tests/regressions/kt456.fir.kt | 30 - .../diagnostics/tests/regressions/kt456.kt | 1 + .../diagnostics/tests/regressions/kt58.fir.kt | 2 +- .../tests/smartCasts/kt3899.fir.kt | 2 +- .../safeCallAndInPlaceReturn.fir.kt | 4 +- .../diagnostics/notLinked/dfa/pos/33.fir.kt | 4 +- .../diagnostics/notLinked/dfa/pos/36.fir.kt | 8 +- .../diagnostics/KtFirDataClassConverters.kt | 7 + .../api/fir/diagnostics/KtFirDiagnostics.kt | 5 + .../fir/diagnostics/KtFirDiagnosticsImpl.kt | 8 + 97 files changed, 939 insertions(+), 1151 deletions(-) create mode 100644 compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirFunctionReturnChecker.kt delete mode 100644 compiler/testData/diagnostics/tests/TypeInference.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturn/ReturnFromFunctionInObject.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturn/kt3444_ReturnFromLocalFunctions.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/controlFlowAnalysis/kt3444.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/dependantOnVarianceNullable.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt1029.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt1031.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt1410.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt2459.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt2842.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt3007.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt3301.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt943.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/reportingImprovements/subtypeForInvariantWithErrorGenerics.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/regressions/kt402.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/regressions/kt442.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/regressions/kt456.fir.kt diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/lambdaInLambda.kt b/compiler/fir/analysis-tests/testData/resolve/arguments/lambdaInLambda.kt index 4f09f96166a..234bcba4c74 100644 --- a/compiler/fir/analysis-tests/testData/resolve/arguments/lambdaInLambda.kt +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/lambdaInLambda.kt @@ -2,7 +2,7 @@ class StringBuilder { fun append(s: String) {} } -fun buildString(init: StringBuilder.() -> Unit): String {} +fun buildString(init: StringBuilder.() -> Unit): String {} interface Template diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/operatorsOverLiterals.kt b/compiler/fir/analysis-tests/testData/resolve/arguments/operatorsOverLiterals.kt index b2b537bd106..d62b07816d3 100644 --- a/compiler/fir/analysis-tests/testData/resolve/arguments/operatorsOverLiterals.kt +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/operatorsOverLiterals.kt @@ -18,10 +18,10 @@ fun test_2(n: Int) { val y = n + 1 } -fun Int.bar(): Int {} +fun Int.bar(): Int {} -fun Int.baz(): Int {} -fun Byte.baz(): Byte {} +fun Int.baz(): Int {} +fun Byte.baz(): Byte {} fun test_3() { val x = 1.bar() diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/flowFromInplaceLambda.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/flowFromInplaceLambda.dot index d6567a732ae..a07048b2eb1 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/flowFromInplaceLambda.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/flowFromInplaceLambda.dot @@ -71,162 +71,163 @@ digraph flowFromInplaceLambda_kt { 21 [label="Enter block"]; 22 [label="Const: Null(null)"]; 23 [label="Check not null: Null(null)!!"]; - 24 [label="Jump: ^materialize Null(null)!!"]; - 25 [label="Stub" style="filled" fillcolor=gray]; - 26 [label="Exit block" style="filled" fillcolor=gray]; + 24 [label="Stub" style="filled" fillcolor=gray]; + 25 [label="Jump: ^materialize Null(null)!!" style="filled" fillcolor=gray]; + 26 [label="Stub" style="filled" fillcolor=gray]; + 27 [label="Exit block" style="filled" fillcolor=gray]; } - 27 [label="Exit function materialize" style="filled" fillcolor=red]; + 28 [label="Exit function materialize" style="filled" fillcolor=red]; } 20 -> {21}; 21 -> {22}; 22 -> {23}; - 23 -> {24}; - 24 -> {27}; + 23 -> {28} [label=onUncaughtException]; + 23 -> {24} [style=dotted]; 24 -> {25} [style=dotted]; - 25 -> {26} [style=dotted]; + 25 -> {28 26} [style=dotted]; 26 -> {27} [style=dotted]; + 27 -> {28} [style=dotted]; subgraph cluster_8 { color=red - 28 [label="Enter function myRun" style="filled" fillcolor=red]; + 29 [label="Enter function myRun" style="filled" fillcolor=red]; subgraph cluster_9 { color=blue - 29 [label="Enter block"]; - 30 [label="Function call: R|/block|.R|SubstitutionOverride|()"]; - 31 [label="Jump: ^myRun R|/block|.R|SubstitutionOverride|()"]; - 32 [label="Stub" style="filled" fillcolor=gray]; - 33 [label="Exit block" style="filled" fillcolor=gray]; + 30 [label="Enter block"]; + 31 [label="Function call: R|/block|.R|SubstitutionOverride|()"]; + 32 [label="Jump: ^myRun R|/block|.R|SubstitutionOverride|()"]; + 33 [label="Stub" style="filled" fillcolor=gray]; + 34 [label="Exit block" style="filled" fillcolor=gray]; } - 34 [label="Exit function myRun" style="filled" fillcolor=red]; + 35 [label="Exit function myRun" style="filled" fillcolor=red]; } - 28 -> {29}; 29 -> {30}; 30 -> {31}; - 31 -> {34}; - 31 -> {32} [style=dotted]; + 31 -> {32}; + 32 -> {35}; 32 -> {33} [style=dotted]; 33 -> {34} [style=dotted]; + 34 -> {35} [style=dotted]; subgraph cluster_10 { color=red - 35 [label="Enter function test_1" style="filled" fillcolor=red]; + 36 [label="Enter function test_1" style="filled" fillcolor=red]; subgraph cluster_11 { color=blue - 36 [label="Enter block"]; - 37 [label="Postponed enter to lambda"]; + 37 [label="Enter block"]; + 38 [label="Postponed enter to lambda"]; subgraph cluster_12 { color=blue - 45 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 46 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; subgraph cluster_13 { color=blue - 46 [label="Enter block"]; - 47 [label="Access variable R|/x|"]; - 48 [label="Type operator: (R|/x| as R|kotlin/Int|)"]; - 49 [label="Exit block"]; + 47 [label="Enter block"]; + 48 [label="Access variable R|/x|"]; + 49 [label="Type operator: (R|/x| as R|kotlin/Int|)"]; + 50 [label="Exit block"]; } - 50 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 51 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 38 [label="Call arguments union" style="filled" fillcolor=yellow]; - 39 [label="Postponed exit from lambda"]; - 40 [label="Function call: R|kotlin/run|(...)"]; - 41 [label="Access variable R|/x|"]; - 42 [label="Function call: R|/takeInt|(...)"]; - 43 [label="Exit block"]; + 39 [label="Call arguments union" style="filled" fillcolor=yellow]; + 40 [label="Postponed exit from lambda"]; + 41 [label="Function call: R|kotlin/run|(...)"]; + 42 [label="Access variable R|/x|"]; + 43 [label="Function call: R|/takeInt|(...)"]; + 44 [label="Exit block"]; } - 44 [label="Exit function test_1" style="filled" fillcolor=red]; + 45 [label="Exit function test_1" style="filled" fillcolor=red]; } - 35 -> {36}; 36 -> {37}; - 37 -> {45}; - 37 -> {39} [color=red]; - 37 -> {45} [style=dashed]; + 37 -> {38}; + 38 -> {46}; 38 -> {40} [color=red]; - 39 -> {40} [color=green]; - 40 -> {41}; + 38 -> {46} [style=dashed]; + 39 -> {41} [color=red]; + 40 -> {41} [color=green]; 41 -> {42}; 42 -> {43}; 43 -> {44}; - 45 -> {46}; + 44 -> {45}; 46 -> {47}; 47 -> {48}; 48 -> {49}; 49 -> {50}; - 50 -> {38} [color=red]; - 50 -> {39} [color=green]; + 50 -> {51}; + 51 -> {39} [color=red]; + 51 -> {40} [color=green]; subgraph cluster_14 { color=red - 51 [label="Enter function test_2" style="filled" fillcolor=red]; + 52 [label="Enter function test_2" style="filled" fillcolor=red]; subgraph cluster_15 { color=blue - 52 [label="Enter block"]; - 53 [label="Postponed enter to lambda"]; + 53 [label="Enter block"]; + 54 [label="Postponed enter to lambda"]; subgraph cluster_16 { color=blue - 74 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 75 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; subgraph cluster_17 { color=blue - 75 [label="Enter block"]; - 76 [label="Access variable R|/y|"]; - 77 [label="Function call: R|/y|.#()"]; - 78 [label="Access variable R|/x|"]; - 79 [label="Type operator: (R|/x| as R|kotlin/Int|)"]; - 80 [label="Exit block"]; + 76 [label="Enter block"]; + 77 [label="Access variable R|/y|"]; + 78 [label="Function call: R|/y|.#()"]; + 79 [label="Access variable R|/x|"]; + 80 [label="Type operator: (R|/x| as R|kotlin/Int|)"]; + 81 [label="Exit block"]; } - 81 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 82 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 54 [label="Postponed exit from lambda"]; - 55 [label="Function call: R|kotlin/run|(...)"]; - 56 [label="Call arguments union" style="filled" fillcolor=yellow]; - 57 [label="Function call: R|/id|(...)"]; - 58 [label="Access variable R|/y|"]; - 59 [label="Type operator: (R|/y| as R|kotlin/Int|)"]; - 60 [label="Postponed enter to lambda"]; + 55 [label="Postponed exit from lambda"]; + 56 [label="Function call: R|kotlin/run|(...)"]; + 57 [label="Call arguments union" style="filled" fillcolor=yellow]; + 58 [label="Function call: R|/id|(...)"]; + 59 [label="Access variable R|/y|"]; + 60 [label="Type operator: (R|/y| as R|kotlin/Int|)"]; + 61 [label="Postponed enter to lambda"]; subgraph cluster_18 { color=blue - 82 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 83 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; subgraph cluster_19 { color=blue - 83 [label="Enter block"]; - 84 [label="Access variable R|/x|"]; - 85 [label="Function call: R|/x|.R|kotlin/Int.inc|()"]; - 86 [label="Access variable R|/y|"]; - 87 [label="Function call: R|/y|.R|kotlin/Int.inc|()"]; - 88 [label="Const: Int(1)"]; - 89 [label="Exit block"]; + 84 [label="Enter block"]; + 85 [label="Access variable R|/x|"]; + 86 [label="Function call: R|/x|.R|kotlin/Int.inc|()"]; + 87 [label="Access variable R|/y|"]; + 88 [label="Function call: R|/y|.R|kotlin/Int.inc|()"]; + 89 [label="Const: Int(1)"]; + 90 [label="Exit block"]; } - 90 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 91 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 61 [label="Postponed exit from lambda"]; - 62 [label="Function call: R|kotlin/run|(...)"]; - 63 [label="Call arguments union" style="filled" fillcolor=yellow]; - 64 [label="Function call: R|/select|(...)"]; - 65 [label="Variable declaration: lval a: R|kotlin/Int|"]; - 66 [label="Access variable R|/x|"]; - 67 [label="Function call: R|/takeInt|(...)"]; - 68 [label="Access variable R|/y|"]; - 69 [label="Function call: R|/takeInt|(...)"]; - 70 [label="Access variable R|/a|"]; - 71 [label="Function call: R|/takeInt|(...)"]; - 72 [label="Exit block"]; + 62 [label="Postponed exit from lambda"]; + 63 [label="Function call: R|kotlin/run|(...)"]; + 64 [label="Call arguments union" style="filled" fillcolor=yellow]; + 65 [label="Function call: R|/select|(...)"]; + 66 [label="Variable declaration: lval a: R|kotlin/Int|"]; + 67 [label="Access variable R|/x|"]; + 68 [label="Function call: R|/takeInt|(...)"]; + 69 [label="Access variable R|/y|"]; + 70 [label="Function call: R|/takeInt|(...)"]; + 71 [label="Access variable R|/a|"]; + 72 [label="Function call: R|/takeInt|(...)"]; + 73 [label="Exit block"]; } - 73 [label="Exit function test_2" style="filled" fillcolor=red]; + 74 [label="Exit function test_2" style="filled" fillcolor=red]; } - 51 -> {52}; 52 -> {53}; - 53 -> {74}; - 53 -> {54} [color=red]; - 53 -> {74} [style=dashed]; - 54 -> {55}; + 53 -> {54}; + 54 -> {75}; + 54 -> {55} [color=red]; + 54 -> {75} [style=dashed]; 55 -> {56}; 56 -> {57}; 57 -> {58}; 58 -> {59}; 59 -> {60}; - 60 -> {82}; - 60 -> {61} [color=red]; - 60 -> {82} [style=dashed]; - 61 -> {62}; + 60 -> {61}; + 61 -> {83}; + 61 -> {62} [color=red]; + 61 -> {83} [style=dashed]; 62 -> {63}; 63 -> {64}; 64 -> {65}; @@ -238,16 +239,16 @@ digraph flowFromInplaceLambda_kt { 70 -> {71}; 71 -> {72}; 72 -> {73}; - 74 -> {75}; + 73 -> {74}; 75 -> {76}; 76 -> {77}; 77 -> {78}; 78 -> {79}; 79 -> {80}; 80 -> {81}; - 81 -> {56} [color=red]; - 81 -> {54} [color=green]; - 82 -> {83}; + 81 -> {82}; + 82 -> {57} [color=red]; + 82 -> {55} [color=green]; 83 -> {84}; 84 -> {85}; 85 -> {86}; @@ -255,79 +256,79 @@ digraph flowFromInplaceLambda_kt { 87 -> {88}; 88 -> {89}; 89 -> {90}; - 90 -> {63} [color=red]; - 90 -> {61} [color=green]; + 90 -> {91}; + 91 -> {64} [color=red]; + 91 -> {62} [color=green]; subgraph cluster_20 { color=red - 91 [label="Enter function test_3" style="filled" fillcolor=red]; + 92 [label="Enter function test_3" style="filled" fillcolor=red]; subgraph cluster_21 { color=blue - 92 [label="Enter block"]; - 93 [label="Postponed enter to lambda"]; + 93 [label="Enter block"]; + 94 [label="Postponed enter to lambda"]; subgraph cluster_22 { color=blue - 111 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 112 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; subgraph cluster_23 { color=blue - 112 [label="Enter block"]; - 113 [label="Access variable R|/y|"]; - 114 [label="Function call: R|/y|.#()"]; - 115 [label="Access variable R|/x|"]; - 116 [label="Type operator: (R|/x| as R|kotlin/Int|)"]; - 117 [label="Function call: R|/materialize|()"]; - 118 [label="Exit block"]; + 113 [label="Enter block"]; + 114 [label="Access variable R|/y|"]; + 115 [label="Function call: R|/y|.#()"]; + 116 [label="Access variable R|/x|"]; + 117 [label="Type operator: (R|/x| as R|kotlin/Int|)"]; + 118 [label="Function call: R|/materialize|()"]; + 119 [label="Exit block"]; } - 119 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 120 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 94 [label="Postponed exit from lambda"]; - 95 [label="Function call: R|kotlin/run|(...)"]; - 96 [label="Function call: R|/id|(...)"]; - 97 [label="Postponed enter to lambda"]; + 95 [label="Postponed exit from lambda"]; + 96 [label="Function call: R|kotlin/run|(...)"]; + 97 [label="Function call: R|/id|(...)"]; + 98 [label="Postponed enter to lambda"]; subgraph cluster_24 { color=blue - 120 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 121 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; subgraph cluster_25 { color=blue - 121 [label="Enter block"]; - 122 [label="Access variable R|/y|"]; - 123 [label="Type operator: (R|/y| as R|kotlin/Int|)"]; - 124 [label="Access variable R|/x|"]; - 125 [label="Function call: R|/x|.#()"]; - 126 [label="Access variable R|/y|"]; - 127 [label="Function call: R|/y|.R|kotlin/Int.inc|()"]; - 128 [label="Const: Int(1)"]; - 129 [label="Exit block"]; + 122 [label="Enter block"]; + 123 [label="Access variable R|/y|"]; + 124 [label="Type operator: (R|/y| as R|kotlin/Int|)"]; + 125 [label="Access variable R|/x|"]; + 126 [label="Function call: R|/x|.#()"]; + 127 [label="Access variable R|/y|"]; + 128 [label="Function call: R|/y|.R|kotlin/Int.inc|()"]; + 129 [label="Const: Int(1)"]; + 130 [label="Exit block"]; } - 130 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 131 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 98 [label="Postponed exit from lambda"]; - 99 [label="Function call: R|kotlin/run|(...)"]; - 100 [label="Call arguments union" style="filled" fillcolor=yellow]; - 101 [label="Function call: R|/select|(...)"]; - 102 [label="Variable declaration: lval a: R|kotlin/Int|"]; - 103 [label="Access variable R|/x|"]; - 104 [label="Function call: R|/takeInt|(...)"]; - 105 [label="Access variable R|/y|"]; - 106 [label="Function call: R|/takeInt|(...)"]; - 107 [label="Access variable R|/a|"]; - 108 [label="Function call: R|/takeInt|(...)"]; - 109 [label="Exit block"]; + 99 [label="Postponed exit from lambda"]; + 100 [label="Function call: R|kotlin/run|(...)"]; + 101 [label="Call arguments union" style="filled" fillcolor=yellow]; + 102 [label="Function call: R|/select|(...)"]; + 103 [label="Variable declaration: lval a: R|kotlin/Int|"]; + 104 [label="Access variable R|/x|"]; + 105 [label="Function call: R|/takeInt|(...)"]; + 106 [label="Access variable R|/y|"]; + 107 [label="Function call: R|/takeInt|(...)"]; + 108 [label="Access variable R|/a|"]; + 109 [label="Function call: R|/takeInt|(...)"]; + 110 [label="Exit block"]; } - 110 [label="Exit function test_3" style="filled" fillcolor=red]; + 111 [label="Exit function test_3" style="filled" fillcolor=red]; } - 91 -> {92}; 92 -> {93}; - 93 -> {111}; - 93 -> {94} [color=red]; - 93 -> {111} [style=dashed]; - 94 -> {95}; + 93 -> {94}; + 94 -> {112}; + 94 -> {95} [color=red]; + 94 -> {112} [style=dashed]; 95 -> {96}; 96 -> {97}; - 97 -> {120}; - 97 -> {98} [color=red]; - 97 -> {120} [style=dashed]; - 98 -> {99}; + 97 -> {98}; + 98 -> {121}; + 98 -> {99} [color=red]; + 98 -> {121} [style=dashed]; 99 -> {100}; 100 -> {101}; 101 -> {102}; @@ -339,7 +340,7 @@ digraph flowFromInplaceLambda_kt { 107 -> {108}; 108 -> {109}; 109 -> {110}; - 111 -> {112}; + 110 -> {111}; 112 -> {113}; 113 -> {114}; 114 -> {115}; @@ -347,9 +348,9 @@ digraph flowFromInplaceLambda_kt { 116 -> {117}; 117 -> {118}; 118 -> {119}; - 119 -> {100} [color=red]; - 119 -> {94} [color=green]; - 120 -> {121}; + 119 -> {120}; + 120 -> {101} [color=red]; + 120 -> {95} [color=green]; 121 -> {122}; 122 -> {123}; 123 -> {124}; @@ -359,77 +360,77 @@ digraph flowFromInplaceLambda_kt { 127 -> {128}; 128 -> {129}; 129 -> {130}; - 130 -> {100} [color=red]; - 130 -> {98} [color=green]; + 130 -> {131}; + 131 -> {101} [color=red]; + 131 -> {99} [color=green]; subgraph cluster_26 { color=red - 131 [label="Enter function test_4" style="filled" fillcolor=red]; + 132 [label="Enter function test_4" style="filled" fillcolor=red]; subgraph cluster_27 { color=blue - 132 [label="Enter block"]; - 133 [label="Postponed enter to lambda"]; + 133 [label="Enter block"]; + 134 [label="Postponed enter to lambda"]; subgraph cluster_28 { color=blue - 152 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 153 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; subgraph cluster_29 { color=blue - 153 [label="Enter block"]; - 154 [label="Access variable R|/y|"]; - 155 [label="Function call: R|/y|.#()"]; - 156 [label="Access variable R|/x|"]; - 157 [label="Type operator: (R|/x| as R|kotlin/Int|)"]; - 158 [label="Exit block"]; + 154 [label="Enter block"]; + 155 [label="Access variable R|/y|"]; + 156 [label="Function call: R|/y|.#()"]; + 157 [label="Access variable R|/x|"]; + 158 [label="Type operator: (R|/x| as R|kotlin/Int|)"]; + 159 [label="Exit block"]; } - 159 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 160 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 134 [label="Postponed exit from lambda"]; - 135 [label="Function call: R|/myRun|(...)"]; - 136 [label="Function call: R|/id|(...)"]; - 137 [label="Access variable R|/y|"]; - 138 [label="Type operator: (R|/y| as R|kotlin/Int|)"]; - 139 [label="Postponed enter to lambda"]; + 135 [label="Postponed exit from lambda"]; + 136 [label="Function call: R|/myRun|(...)"]; + 137 [label="Function call: R|/id|(...)"]; + 138 [label="Access variable R|/y|"]; + 139 [label="Type operator: (R|/y| as R|kotlin/Int|)"]; + 140 [label="Postponed enter to lambda"]; subgraph cluster_30 { color=blue - 160 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 161 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; subgraph cluster_31 { color=blue - 161 [label="Enter block"]; - 162 [label="Access variable R|/x|"]; - 163 [label="Function call: R|/x|.#()"]; - 164 [label="Access variable R|/y|"]; - 165 [label="Function call: R|/y|.R|kotlin/Int.inc|()"]; - 166 [label="Const: Int(1)"]; - 167 [label="Exit block"]; + 162 [label="Enter block"]; + 163 [label="Access variable R|/x|"]; + 164 [label="Function call: R|/x|.#()"]; + 165 [label="Access variable R|/y|"]; + 166 [label="Function call: R|/y|.R|kotlin/Int.inc|()"]; + 167 [label="Const: Int(1)"]; + 168 [label="Exit block"]; } - 168 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 169 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 140 [label="Postponed exit from lambda"]; - 141 [label="Function call: R|/myRun|(...)"]; - 142 [label="Function call: R|/select|(...)"]; - 143 [label="Variable declaration: lval a: R|kotlin/Int|"]; - 144 [label="Access variable R|/x|"]; - 145 [label="Function call: #(...)"]; - 146 [label="Access variable R|/y|"]; - 147 [label="Function call: R|/takeInt|(...)"]; - 148 [label="Access variable R|/a|"]; - 149 [label="Function call: R|/takeInt|(...)"]; - 150 [label="Exit block"]; + 141 [label="Postponed exit from lambda"]; + 142 [label="Function call: R|/myRun|(...)"]; + 143 [label="Function call: R|/select|(...)"]; + 144 [label="Variable declaration: lval a: R|kotlin/Int|"]; + 145 [label="Access variable R|/x|"]; + 146 [label="Function call: #(...)"]; + 147 [label="Access variable R|/y|"]; + 148 [label="Function call: R|/takeInt|(...)"]; + 149 [label="Access variable R|/a|"]; + 150 [label="Function call: R|/takeInt|(...)"]; + 151 [label="Exit block"]; } - 151 [label="Exit function test_4" style="filled" fillcolor=red]; + 152 [label="Exit function test_4" style="filled" fillcolor=red]; } - 131 -> {132}; 132 -> {133}; - 133 -> {134 152}; - 133 -> {152} [style=dashed]; - 134 -> {135}; + 133 -> {134}; + 134 -> {135 153}; + 134 -> {153} [style=dashed]; 135 -> {136}; 136 -> {137}; 137 -> {138}; 138 -> {139}; - 139 -> {140 160}; - 139 -> {160} [style=dashed]; - 140 -> {141}; + 139 -> {140}; + 140 -> {141 161}; + 140 -> {161} [style=dashed]; 141 -> {142}; 142 -> {143}; 143 -> {144}; @@ -440,14 +441,14 @@ digraph flowFromInplaceLambda_kt { 148 -> {149}; 149 -> {150}; 150 -> {151}; - 152 -> {153}; + 151 -> {152}; 153 -> {154}; 154 -> {155}; 155 -> {156}; 156 -> {157}; 157 -> {158}; 158 -> {159}; - 160 -> {161}; + 159 -> {160}; 161 -> {162}; 162 -> {163}; 163 -> {164}; @@ -455,61 +456,61 @@ digraph flowFromInplaceLambda_kt { 165 -> {166}; 166 -> {167}; 167 -> {168}; + 168 -> {169}; subgraph cluster_32 { color=red - 169 [label="Enter function test_5" style="filled" fillcolor=red]; + 170 [label="Enter function test_5" style="filled" fillcolor=red]; subgraph cluster_33 { color=blue - 170 [label="Enter block"]; - 171 [label="Postponed enter to lambda"]; + 171 [label="Enter block"]; + 172 [label="Postponed enter to lambda"]; subgraph cluster_34 { color=blue - 184 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 185 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; subgraph cluster_35 { color=blue - 185 [label="Enter block"]; - 186 [label="Function call: R|/materialize|()"]; - 187 [label="Exit block"]; + 186 [label="Enter block"]; + 187 [label="Function call: R|/materialize|()"]; + 188 [label="Exit block"]; } - 188 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 189 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 172 [label="Postponed exit from lambda"]; - 173 [label="Function call: R|kotlin/run|(...)"]; - 174 [label="Postponed enter to lambda"]; + 173 [label="Postponed exit from lambda"]; + 174 [label="Function call: R|kotlin/run|(...)"]; + 175 [label="Postponed enter to lambda"]; subgraph cluster_36 { color=blue - 189 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 190 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; subgraph cluster_37 { color=blue - 190 [label="Enter block"]; - 191 [label="Function call: R|/materialize|()"]; - 192 [label="Exit block"]; + 191 [label="Enter block"]; + 192 [label="Function call: R|/materialize|()"]; + 193 [label="Exit block"]; } - 193 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 194 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 175 [label="Postponed exit from lambda"]; - 176 [label="Function call: R|kotlin/run|(...)"]; - 177 [label="Call arguments union" style="filled" fillcolor=yellow]; - 178 [label="Function call: R|/select|(...)"]; - 179 [label="Variable declaration: lval x: R|kotlin/Int|"]; - 180 [label="Access variable R|/x|"]; - 181 [label="Function call: R|/takeInt|(...)"]; - 182 [label="Exit block"]; + 176 [label="Postponed exit from lambda"]; + 177 [label="Function call: R|kotlin/run|(...)"]; + 178 [label="Call arguments union" style="filled" fillcolor=yellow]; + 179 [label="Function call: R|/select|(...)"]; + 180 [label="Variable declaration: lval x: R|kotlin/Int|"]; + 181 [label="Access variable R|/x|"]; + 182 [label="Function call: R|/takeInt|(...)"]; + 183 [label="Exit block"]; } - 183 [label="Exit function test_5" style="filled" fillcolor=red]; + 184 [label="Exit function test_5" style="filled" fillcolor=red]; } - 169 -> {170}; 170 -> {171}; - 171 -> {184}; - 171 -> {172} [color=red]; - 171 -> {184} [style=dashed]; - 172 -> {173}; + 171 -> {172}; + 172 -> {185}; + 172 -> {173} [color=red]; + 172 -> {185} [style=dashed]; 173 -> {174}; - 174 -> {189}; - 174 -> {175} [color=red]; - 174 -> {189} [style=dashed]; - 175 -> {176}; + 174 -> {175}; + 175 -> {190}; + 175 -> {176} [color=red]; + 175 -> {190} [style=dashed]; 176 -> {177}; 177 -> {178}; 178 -> {179}; @@ -517,79 +518,80 @@ digraph flowFromInplaceLambda_kt { 180 -> {181}; 181 -> {182}; 182 -> {183}; - 184 -> {185}; + 183 -> {184}; 185 -> {186}; 186 -> {187}; 187 -> {188}; - 188 -> {177} [color=red]; - 188 -> {172} [color=green]; - 189 -> {190}; + 188 -> {189}; + 189 -> {178} [color=red]; + 189 -> {173} [color=green]; 190 -> {191}; 191 -> {192}; 192 -> {193}; - 193 -> {177} [color=red]; - 193 -> {175} [color=green]; + 193 -> {194}; + 194 -> {178} [color=red]; + 194 -> {176} [color=green]; subgraph cluster_38 { color=red - 194 [label="Enter function test_6" style="filled" fillcolor=red]; + 195 [label="Enter function test_6" style="filled" fillcolor=red]; subgraph cluster_39 { color=blue - 195 [label="Enter block"]; - 196 [label="Postponed enter to lambda"]; + 196 [label="Enter block"]; + 197 [label="Postponed enter to lambda"]; subgraph cluster_40 { color=blue - 203 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 204 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; subgraph cluster_41 { color=blue - 204 [label="Enter block"]; - 205 [label="Postponed enter to lambda"]; + 205 [label="Enter block"]; + 206 [label="Postponed enter to lambda"]; subgraph cluster_42 { color=blue - 210 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 211 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; subgraph cluster_43 { color=blue - 211 [label="Enter block"]; - 212 [label="Function call: R|/materialize|()"]; - 213 [label="Exit block"]; + 212 [label="Enter block"]; + 213 [label="Function call: R|/materialize|()"]; + 214 [label="Exit block"]; } - 214 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 215 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 206 [label="Postponed exit from lambda"]; - 207 [label="Function call: R|kotlin/run|(...)"]; - 208 [label="Exit block"]; + 207 [label="Postponed exit from lambda"]; + 208 [label="Function call: R|kotlin/run|(...)"]; + 209 [label="Exit block"]; } - 209 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 210 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 197 [label="Postponed exit from lambda"]; - 198 [label="Function call: R|/myRun|(...)"]; - 199 [label="Function call: R|/id|(...)"]; - 200 [label="Variable declaration: lval x: R|kotlin/String|"]; - 201 [label="Exit block"]; + 198 [label="Postponed exit from lambda"]; + 199 [label="Function call: R|/myRun|(...)"]; + 200 [label="Function call: R|/id|(...)"]; + 201 [label="Variable declaration: lval x: R|kotlin/String|"]; + 202 [label="Exit block"]; } - 202 [label="Exit function test_6" style="filled" fillcolor=red]; + 203 [label="Exit function test_6" style="filled" fillcolor=red]; } - 194 -> {195}; 195 -> {196}; - 196 -> {197 203}; - 196 -> {203} [style=dashed]; - 197 -> {198}; + 196 -> {197}; + 197 -> {198 204}; + 197 -> {204} [style=dashed]; 198 -> {199}; 199 -> {200}; 200 -> {201}; 201 -> {202}; - 203 -> {204}; + 202 -> {203}; 204 -> {205}; - 205 -> {210}; - 205 -> {206} [color=red]; - 205 -> {210} [style=dashed]; - 206 -> {207}; + 205 -> {206}; + 206 -> {211}; + 206 -> {207} [color=red]; + 206 -> {211} [style=dashed]; 207 -> {208}; 208 -> {209}; - 210 -> {211}; + 209 -> {210}; 211 -> {212}; 212 -> {213}; 213 -> {214}; - 214 -> {206} [color=green]; + 214 -> {215}; + 215 -> {207} [color=green]; } diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/inplaceLambdaInControlFlowExpressions.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/inplaceLambdaInControlFlowExpressions.dot index e9de33a5a30..7c63fa016c3 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/inplaceLambdaInControlFlowExpressions.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/inplaceLambdaInControlFlowExpressions.dot @@ -11,175 +11,176 @@ digraph inplaceLambdaInControlFlowExpressions_kt { 1 [label="Enter block"]; 2 [label="Const: Null(null)"]; 3 [label="Check not null: Null(null)!!"]; - 4 [label="Jump: ^materialize Null(null)!!"]; - 5 [label="Stub" style="filled" fillcolor=gray]; - 6 [label="Exit block" style="filled" fillcolor=gray]; + 4 [label="Stub" style="filled" fillcolor=gray]; + 5 [label="Jump: ^materialize Null(null)!!" style="filled" fillcolor=gray]; + 6 [label="Stub" style="filled" fillcolor=gray]; + 7 [label="Exit block" style="filled" fillcolor=gray]; } - 7 [label="Exit function materialize" style="filled" fillcolor=red]; + 8 [label="Exit function materialize" style="filled" fillcolor=red]; } 0 -> {1}; 1 -> {2}; 2 -> {3}; - 3 -> {4}; - 4 -> {7}; + 3 -> {8} [label=onUncaughtException]; + 3 -> {4} [style=dotted]; 4 -> {5} [style=dotted]; - 5 -> {6} [style=dotted]; + 5 -> {8 6} [style=dotted]; 6 -> {7} [style=dotted]; + 7 -> {8} [style=dotted]; subgraph cluster_2 { color=red - 8 [label="Enter function test_1" style="filled" fillcolor=red]; + 9 [label="Enter function test_1" style="filled" fillcolor=red]; subgraph cluster_3 { color=blue - 9 [label="Enter block"]; + 10 [label="Enter block"]; subgraph cluster_4 { color=blue - 10 [label="Enter when"]; + 11 [label="Enter when"]; subgraph cluster_5 { color=blue - 11 [label="Enter when branch condition "]; - 12 [label="Const: Boolean(true)"]; - 13 [label="Exit when branch condition"]; + 12 [label="Enter when branch condition "]; + 13 [label="Const: Boolean(true)"]; + 14 [label="Exit when branch condition"]; } subgraph cluster_6 { color=blue - 14 [label="Enter when branch condition else"]; - 15 [label="Exit when branch condition"]; + 15 [label="Enter when branch condition else"]; + 16 [label="Exit when branch condition"]; } - 16 [label="Enter when branch result"]; + 17 [label="Enter when branch result"]; subgraph cluster_7 { color=blue - 17 [label="Enter block"]; - 18 [label="Const: String()"]; - 19 [label="Exit block"]; + 18 [label="Enter block"]; + 19 [label="Const: String()"]; + 20 [label="Exit block"]; } - 20 [label="Exit when branch result"]; - 21 [label="Enter when branch result"]; + 21 [label="Exit when branch result"]; + 22 [label="Enter when branch result"]; subgraph cluster_8 { color=blue - 22 [label="Enter block"]; - 23 [label="Postponed enter to lambda"]; + 23 [label="Enter block"]; + 24 [label="Postponed enter to lambda"]; subgraph cluster_9 { color=blue - 32 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 33 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; subgraph cluster_10 { color=blue - 33 [label="Enter block"]; - 34 [label="Function call: R|/materialize|()"]; - 35 [label="Exit block"]; + 34 [label="Enter block"]; + 35 [label="Function call: R|/materialize|()"]; + 36 [label="Exit block"]; } - 36 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 37 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 24 [label="Postponed exit from lambda"]; - 25 [label="Function call: R|kotlin/run|(...)"]; - 26 [label="Exit block"]; + 25 [label="Postponed exit from lambda"]; + 26 [label="Function call: R|kotlin/run|(...)"]; + 27 [label="Exit block"]; } - 27 [label="Exit when branch result"]; - 28 [label="Exit when"]; + 28 [label="Exit when branch result"]; + 29 [label="Exit when"]; } - 29 [label="Variable declaration: lval x: R|kotlin/String|"]; - 30 [label="Exit block"]; + 30 [label="Variable declaration: lval x: R|kotlin/String|"]; + 31 [label="Exit block"]; } - 31 [label="Exit function test_1" style="filled" fillcolor=red]; + 32 [label="Exit function test_1" style="filled" fillcolor=red]; } - 8 -> {9}; 9 -> {10}; 10 -> {11}; 11 -> {12}; 12 -> {13}; - 13 -> {21 14}; - 14 -> {15}; + 13 -> {14}; + 14 -> {22 15}; 15 -> {16}; 16 -> {17}; 17 -> {18}; 18 -> {19}; 19 -> {20}; - 20 -> {28}; - 21 -> {22}; + 20 -> {21}; + 21 -> {29}; 22 -> {23}; - 23 -> {32}; - 23 -> {24} [color=red]; - 23 -> {32} [style=dashed]; - 24 -> {25}; + 23 -> {24}; + 24 -> {33}; + 24 -> {25} [color=red]; + 24 -> {33} [style=dashed]; 25 -> {26}; 26 -> {27}; 27 -> {28}; 28 -> {29}; 29 -> {30}; 30 -> {31}; - 32 -> {33}; + 31 -> {32}; 33 -> {34}; 34 -> {35}; 35 -> {36}; - 36 -> {24} [color=green]; + 36 -> {37}; + 37 -> {25} [color=green]; subgraph cluster_11 { color=red - 37 [label="Enter function test_2" style="filled" fillcolor=red]; + 38 [label="Enter function test_2" style="filled" fillcolor=red]; subgraph cluster_12 { color=blue - 38 [label="Enter block"]; + 39 [label="Enter block"]; subgraph cluster_13 { color=blue - 39 [label="Try expression enter"]; + 40 [label="Try expression enter"]; subgraph cluster_14 { color=blue - 40 [label="Try main block enter"]; + 41 [label="Try main block enter"]; subgraph cluster_15 { color=blue - 41 [label="Enter block"]; - 42 [label="Postponed enter to lambda"]; + 42 [label="Enter block"]; + 43 [label="Postponed enter to lambda"]; subgraph cluster_16 { color=blue - 57 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 58 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; subgraph cluster_17 { color=blue - 58 [label="Enter block"]; - 59 [label="Function call: R|/materialize|()"]; - 60 [label="Exit block"]; + 59 [label="Enter block"]; + 60 [label="Function call: R|/materialize|()"]; + 61 [label="Exit block"]; } - 61 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 62 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 43 [label="Postponed exit from lambda"]; - 44 [label="Function call: R|kotlin/run|(...)"]; - 45 [label="Exit block"]; + 44 [label="Postponed exit from lambda"]; + 45 [label="Function call: R|kotlin/run|(...)"]; + 46 [label="Exit block"]; } - 46 [label="Try main block exit"]; + 47 [label="Try main block exit"]; } subgraph cluster_18 { color=blue - 47 [label="Catch enter"]; + 48 [label="Catch enter"]; subgraph cluster_19 { color=blue - 48 [label="Enter block"]; - 49 [label="Const: String()"]; - 50 [label="Exit block"]; + 49 [label="Enter block"]; + 50 [label="Const: String()"]; + 51 [label="Exit block"]; } - 51 [label="Catch exit"]; + 52 [label="Catch exit"]; } - 52 [label="Try expression exit"]; + 53 [label="Try expression exit"]; } - 53 [label="Call arguments union" style="filled" fillcolor=yellow]; - 54 [label="Variable declaration: lval x: R|kotlin/String|"]; - 55 [label="Exit block"]; + 54 [label="Call arguments union" style="filled" fillcolor=yellow]; + 55 [label="Variable declaration: lval x: R|kotlin/String|"]; + 56 [label="Exit block"]; } - 56 [label="Exit function test_2" style="filled" fillcolor=red]; + 57 [label="Exit function test_2" style="filled" fillcolor=red]; } - 37 -> {38}; 38 -> {39}; - 39 -> {40 47}; - 40 -> {41}; + 39 -> {40}; + 40 -> {41 48}; 41 -> {42}; - 42 -> {57}; - 42 -> {43} [color=red]; - 42 -> {57} [style=dashed]; - 43 -> {44}; + 42 -> {43}; + 43 -> {58}; + 43 -> {44} [color=red]; + 43 -> {58} [style=dashed]; 44 -> {45}; 45 -> {46}; - 46 -> {52 47}; - 47 -> {48}; - 47 -> {56} [label=onUncaughtException]; + 46 -> {47}; + 47 -> {53 48}; 48 -> {49}; + 48 -> {57} [label=onUncaughtException]; 49 -> {50}; 50 -> {51}; 51 -> {52}; @@ -187,56 +188,57 @@ digraph inplaceLambdaInControlFlowExpressions_kt { 53 -> {54}; 54 -> {55}; 55 -> {56}; - 57 -> {58}; + 56 -> {57}; 58 -> {59}; 59 -> {60}; 60 -> {61}; - 61 -> {53} [color=red]; - 61 -> {43} [color=green]; + 61 -> {62}; + 62 -> {54} [color=red]; + 62 -> {44} [color=green]; subgraph cluster_20 { color=red - 62 [label="Enter function test_3" style="filled" fillcolor=red]; + 63 [label="Enter function test_3" style="filled" fillcolor=red]; subgraph cluster_21 { color=blue - 63 [label="Enter block"]; - 64 [label="Postponed enter to lambda"]; + 64 [label="Enter block"]; + 65 [label="Postponed enter to lambda"]; subgraph cluster_22 { color=blue - 72 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 73 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; subgraph cluster_23 { color=blue - 73 [label="Enter block"]; - 74 [label="Function call: R|/materialize|()"]; - 75 [label="Exit block"]; + 74 [label="Enter block"]; + 75 [label="Function call: R|/materialize|()"]; + 76 [label="Exit block"]; } - 76 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 77 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 65 [label="Postponed exit from lambda"]; - 66 [label="Function call: R|kotlin/run|(...)"]; - 67 [label="Check not null: R|kotlin/run|(...)!!"]; - 68 [label="Call arguments union" style="filled" fillcolor=yellow]; - 69 [label="Variable declaration: lval x: R|kotlin/String|"]; - 70 [label="Exit block"]; + 66 [label="Postponed exit from lambda"]; + 67 [label="Function call: R|kotlin/run|(...)"]; + 68 [label="Check not null: R|kotlin/run|(...)!!"]; + 69 [label="Call arguments union" style="filled" fillcolor=yellow]; + 70 [label="Variable declaration: lval x: R|kotlin/String|"]; + 71 [label="Exit block"]; } - 71 [label="Exit function test_3" style="filled" fillcolor=red]; + 72 [label="Exit function test_3" style="filled" fillcolor=red]; } - 62 -> {63}; 63 -> {64}; - 64 -> {72}; - 64 -> {65} [color=red]; - 64 -> {72} [style=dashed]; - 65 -> {66}; + 64 -> {65}; + 65 -> {73}; + 65 -> {66} [color=red]; + 65 -> {73} [style=dashed]; 66 -> {67}; 67 -> {68}; 68 -> {69}; 69 -> {70}; 70 -> {71}; - 72 -> {73}; + 71 -> {72}; 73 -> {74}; 74 -> {75}; 75 -> {76}; - 76 -> {68} [color=red]; - 76 -> {65} [color=green]; + 76 -> {77}; + 77 -> {69} [color=red]; + 77 -> {66} [color=green]; } diff --git a/compiler/fir/analysis-tests/testData/resolve/constantValues.kt b/compiler/fir/analysis-tests/testData/resolve/constantValues.kt index 7e6b5b5d5a1..c6360e59043 100644 --- a/compiler/fir/analysis-tests/testData/resolve/constantValues.kt +++ b/compiler/fir/analysis-tests/testData/resolve/constantValues.kt @@ -22,5 +22,5 @@ class KClassValue(value: Value) : ConstantValue(value) { val (classId, arrayDimensions) = value.value } } - } + } } diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/operators/plusAndPlusAssign.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/operators/plusAndPlusAssign.kt index 10dd9c63aab..e82fac51f7d 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/operators/plusAndPlusAssign.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/operators/plusAndPlusAssign.kt @@ -1,5 +1,5 @@ class Foo { - operator fun plus(f: Foo): Foo {} + operator fun plus(f: Foo): Foo {} operator fun plusAssign(f: Foo) {} } diff --git a/compiler/fir/analysis-tests/testData/resolve/functionTypes.kt b/compiler/fir/analysis-tests/testData/resolve/functionTypes.kt index c129c99f8b2..dff5aba55f6 100644 --- a/compiler/fir/analysis-tests/testData/resolve/functionTypes.kt +++ b/compiler/fir/analysis-tests/testData/resolve/functionTypes.kt @@ -2,7 +2,7 @@ fun simpleRun(f: (T) -> Unit): Unit = f( List.simpleMap(f: (T) -> R): R { -} +} fun simpleWith(t: T, f: T.() -> Unit): Unit = t.f() diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/compilerPhase.kt b/compiler/fir/analysis-tests/testData/resolve/problems/compilerPhase.kt index 7a1446811da..51d7d2de5be 100644 --- a/compiler/fir/analysis-tests/testData/resolve/problems/compilerPhase.kt +++ b/compiler/fir/analysis-tests/testData/resolve/problems/compilerPhase.kt @@ -32,7 +32,7 @@ class NamedCompilerPhase( } } runAfter(phaseConfig, phaserState, context, output) - } + } private fun runAfter(phaseConfig: PhaseConfig, phaserState: PhaserState, context: Context, output: Data) { @@ -40,5 +40,5 @@ class NamedCompilerPhase( private fun runAndProfile(phaseConfig: PhaseConfig, phaserState: PhaserState, context: Context, source: Data): Data { - } -} \ No newline at end of file + } +} diff --git a/compiler/fir/analysis-tests/testData/resolve/properties/kotlinOverridesJavaComplex.kt b/compiler/fir/analysis-tests/testData/resolve/properties/kotlinOverridesJavaComplex.kt index 7f5d6fa954c..2258c731dee 100644 --- a/compiler/fir/analysis-tests/testData/resolve/properties/kotlinOverridesJavaComplex.kt +++ b/compiler/fir/analysis-tests/testData/resolve/properties/kotlinOverridesJavaComplex.kt @@ -33,7 +33,7 @@ public interface Klass extends TypeParametersOwner { fun List.single(): String = "" fun List.single(): Int = 2 -fun listOf(): List {} +fun listOf(): List {} public open class LightMember : Member, Light() { override fun getName(): String = "Light" diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToNothing.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToNothing.dot index 563e8bb1102..6b2e9ea5e89 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToNothing.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToNothing.dot @@ -99,157 +99,158 @@ digraph smartcastToNothing_kt { 31 [label="Enter block"]; 32 [label="Const: Null(null)"]; 33 [label="Check not null: Null(null)!!"]; - 34 [label="Jump: ^myListOf Null(null)!!"]; - 35 [label="Stub" style="filled" fillcolor=gray]; - 36 [label="Exit block" style="filled" fillcolor=gray]; + 34 [label="Stub" style="filled" fillcolor=gray]; + 35 [label="Jump: ^myListOf Null(null)!!" style="filled" fillcolor=gray]; + 36 [label="Stub" style="filled" fillcolor=gray]; + 37 [label="Exit block" style="filled" fillcolor=gray]; } - 37 [label="Exit function myListOf" style="filled" fillcolor=red]; + 38 [label="Exit function myListOf" style="filled" fillcolor=red]; } 30 -> {31}; 31 -> {32}; 32 -> {33}; - 33 -> {34}; - 34 -> {37}; + 33 -> {38} [label=onUncaughtException]; + 33 -> {34} [style=dotted]; 34 -> {35} [style=dotted]; - 35 -> {36} [style=dotted]; + 35 -> {38 36} [style=dotted]; 36 -> {37} [style=dotted]; + 37 -> {38} [style=dotted]; subgraph cluster_10 { color=red - 38 [label="Enter function " style="filled" fillcolor=red]; - 39 [label="Delegated constructor call: super()"]; - 40 [label="Exit function " style="filled" fillcolor=red]; + 39 [label="Enter function " style="filled" fillcolor=red]; + 40 [label="Delegated constructor call: super()"]; + 41 [label="Exit function " style="filled" fillcolor=red]; } - 38 -> {39}; 39 -> {40}; + 40 -> {41}; subgraph cluster_11 { color=red - 41 [label="Enter property" style="filled" fillcolor=red]; - 42 [label="Const: Int(1)"]; - 43 [label="Exit property" style="filled" fillcolor=red]; + 42 [label="Enter property" style="filled" fillcolor=red]; + 43 [label="Const: Int(1)"]; + 44 [label="Exit property" style="filled" fillcolor=red]; } - 41 -> {42}; 42 -> {43}; - 43 -> {49} [color=green]; + 43 -> {44}; + 44 -> {50} [color=green]; subgraph cluster_12 { color=red - 44 [label="Enter property" style="filled" fillcolor=red]; - 45 [label="Const: Boolean(true)"]; - 46 [label="Exit property" style="filled" fillcolor=red]; + 45 [label="Enter property" style="filled" fillcolor=red]; + 46 [label="Const: Boolean(true)"]; + 47 [label="Exit property" style="filled" fillcolor=red]; } - 44 -> {45}; 45 -> {46}; - 46 -> {50} [color=green]; + 46 -> {47}; + 47 -> {51} [color=green]; subgraph cluster_13 { color=red - 47 [label="Enter class A" style="filled" fillcolor=red]; - 48 [label="Part of class initialization"]; + 48 [label="Enter class A" style="filled" fillcolor=red]; 49 [label="Part of class initialization"]; - 50 [label="Exit class A" style="filled" fillcolor=red]; + 50 [label="Part of class initialization"]; + 51 [label="Exit class A" style="filled" fillcolor=red]; } - 47 -> {48} [color=green]; - 48 -> {49} [style=dotted]; - 48 -> {41} [color=green]; - 48 -> {41} [style=dashed]; + 48 -> {49} [color=green]; 49 -> {50} [style=dotted]; - 49 -> {44} [color=green]; - 49 -> {44} [style=dashed]; + 49 -> {42} [color=green]; + 49 -> {42} [style=dashed]; + 50 -> {51} [style=dotted]; + 50 -> {45} [color=green]; + 50 -> {45} [style=dashed]; subgraph cluster_14 { color=red - 51 [label="Enter function test_0" style="filled" fillcolor=red]; + 52 [label="Enter function test_0" style="filled" fillcolor=red]; subgraph cluster_15 { color=blue - 52 [label="Enter block"]; - 53 [label="Const: Null(null)"]; - 54 [label="Variable declaration: lvar s: R|A?|"]; + 53 [label="Enter block"]; + 54 [label="Const: Null(null)"]; + 55 [label="Variable declaration: lvar s: R|A?|"]; subgraph cluster_16 { color=blue - 55 [label="Enter block"]; - 56 [label="Access variable R|/results|"]; - 57 [label="Function call: R|/results|.R|SubstitutionOverride|>|()"]; - 58 [label="Variable declaration: lval : R|kotlin/collections/Iterator|"]; + 56 [label="Enter block"]; + 57 [label="Access variable R|/results|"]; + 58 [label="Function call: R|/results|.R|SubstitutionOverride|>|()"]; + 59 [label="Variable declaration: lval : R|kotlin/collections/Iterator|"]; subgraph cluster_17 { color=blue - 59 [label="Enter while loop"]; + 60 [label="Enter while loop"]; subgraph cluster_18 { color=blue - 60 [label="Enter loop condition"]; - 61 [label="Access variable R|/|"]; - 62 [label="Function call: R|/|.R|kotlin/collections/Iterator.hasNext|()"]; - 63 [label="Exit loop condition"]; + 61 [label="Enter loop condition"]; + 62 [label="Access variable R|/|"]; + 63 [label="Function call: R|/|.R|kotlin/collections/Iterator.hasNext|()"]; + 64 [label="Exit loop condition"]; } subgraph cluster_19 { color=blue - 64 [label="Enter loop block"]; + 65 [label="Enter loop block"]; subgraph cluster_20 { color=blue - 65 [label="Enter block"]; - 66 [label="Access variable R|/|"]; - 67 [label="Function call: R|/|.R|SubstitutionOverride|()"]; - 68 [label="Stub" style="filled" fillcolor=gray]; - 69 [label="Variable declaration: lval result: R|kotlin/Nothing|" style="filled" fillcolor=gray]; - 70 [label="Access variable R|/result|" style="filled" fillcolor=gray]; - 71 [label="Stub" style="filled" fillcolor=gray]; - 72 [label="Assignment: R|/s|" style="filled" fillcolor=gray]; + 66 [label="Enter block"]; + 67 [label="Access variable R|/|"]; + 68 [label="Function call: R|/|.R|SubstitutionOverride|()"]; + 69 [label="Stub" style="filled" fillcolor=gray]; + 70 [label="Variable declaration: lval result: R|kotlin/Nothing|" style="filled" fillcolor=gray]; + 71 [label="Access variable R|/result|" style="filled" fillcolor=gray]; + 72 [label="Stub" style="filled" fillcolor=gray]; + 73 [label="Assignment: R|/s|" style="filled" fillcolor=gray]; subgraph cluster_21 { color=blue - 73 [label="Enter when" style="filled" fillcolor=gray]; + 74 [label="Enter when" style="filled" fillcolor=gray]; subgraph cluster_22 { color=blue - 74 [label="Enter when branch condition " style="filled" fillcolor=gray]; - 75 [label="Access variable R|/result|" style="filled" fillcolor=gray]; - 76 [label="Stub" style="filled" fillcolor=gray]; - 77 [label="Access variable #" style="filled" fillcolor=gray]; - 78 [label="Exit when branch condition" style="filled" fillcolor=gray]; + 75 [label="Enter when branch condition " style="filled" fillcolor=gray]; + 76 [label="Access variable R|/result|" style="filled" fillcolor=gray]; + 77 [label="Stub" style="filled" fillcolor=gray]; + 78 [label="Access variable #" style="filled" fillcolor=gray]; + 79 [label="Exit when branch condition" style="filled" fillcolor=gray]; } - 79 [label="Synthetic else branch" style="filled" fillcolor=gray]; - 80 [label="Enter when branch result" style="filled" fillcolor=gray]; + 80 [label="Synthetic else branch" style="filled" fillcolor=gray]; + 81 [label="Enter when branch result" style="filled" fillcolor=gray]; subgraph cluster_23 { color=blue - 81 [label="Enter block" style="filled" fillcolor=gray]; - 82 [label="Jump: break@@@[R|/|.R|kotlin/collections/Iterator.hasNext|()] " style="filled" fillcolor=gray]; - 83 [label="Stub" style="filled" fillcolor=gray]; - 84 [label="Exit block" style="filled" fillcolor=gray]; + 82 [label="Enter block" style="filled" fillcolor=gray]; + 83 [label="Jump: break@@@[R|/|.R|kotlin/collections/Iterator.hasNext|()] " style="filled" fillcolor=gray]; + 84 [label="Stub" style="filled" fillcolor=gray]; + 85 [label="Exit block" style="filled" fillcolor=gray]; } - 85 [label="Exit when branch result" style="filled" fillcolor=gray]; - 86 [label="Exit when" style="filled" fillcolor=gray]; + 86 [label="Exit when branch result" style="filled" fillcolor=gray]; + 87 [label="Exit when" style="filled" fillcolor=gray]; } - 87 [label="Exit block" style="filled" fillcolor=gray]; + 88 [label="Exit block" style="filled" fillcolor=gray]; } - 88 [label="Exit loop block" style="filled" fillcolor=gray]; + 89 [label="Exit loop block" style="filled" fillcolor=gray]; } - 89 [label="Exit whileloop"]; + 90 [label="Exit whileloop"]; } - 90 [label="Exit block"]; + 91 [label="Exit block"]; } - 91 [label="Access variable R|/s|"]; - 92 [label="Enter safe call"]; - 93 [label="Postponed enter to lambda"]; + 92 [label="Access variable R|/s|"]; + 93 [label="Enter safe call"]; + 94 [label="Postponed enter to lambda"]; subgraph cluster_24 { color=blue - 100 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 101 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; subgraph cluster_25 { color=blue - 101 [label="Enter block"]; - 102 [label="Access variable R|/it|"]; - 103 [label="Access variable R|/A.a|"]; - 104 [label="Exit block"]; + 102 [label="Enter block"]; + 103 [label="Access variable R|/it|"]; + 104 [label="Access variable R|/A.a|"]; + 105 [label="Exit block"]; } - 105 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 106 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 94 [label="Call arguments union" style="filled" fillcolor=yellow]; - 95 [label="Postponed exit from lambda"]; - 96 [label="Function call: $subj$.R|kotlin/let|(...)"]; - 97 [label="Exit safe call"]; - 98 [label="Exit block"]; + 95 [label="Call arguments union" style="filled" fillcolor=yellow]; + 96 [label="Postponed exit from lambda"]; + 97 [label="Function call: $subj$.R|kotlin/let|(...)"]; + 98 [label="Exit safe call"]; + 99 [label="Exit block"]; } - 99 [label="Exit function test_0" style="filled" fillcolor=red]; + 100 [label="Exit function test_0" style="filled" fillcolor=red]; } - 51 -> {52}; 52 -> {53}; 53 -> {54}; 54 -> {55}; @@ -261,53 +262,54 @@ digraph smartcastToNothing_kt { 60 -> {61}; 61 -> {62}; 62 -> {63}; - 63 -> {89 64}; - 64 -> {65}; + 63 -> {64}; + 64 -> {90 65}; 65 -> {66}; 66 -> {67}; - 67 -> {99} [label=onUncaughtException]; - 67 -> {68} [style=dotted]; + 67 -> {68}; + 68 -> {100} [label=onUncaughtException]; 68 -> {69} [style=dotted]; 69 -> {70} [style=dotted]; 70 -> {71} [style=dotted]; - 70 -> {99} [style=dotted] [label=onUncaughtException]; 71 -> {72} [style=dotted]; + 71 -> {100} [style=dotted] [label=onUncaughtException]; 72 -> {73} [style=dotted]; 73 -> {74} [style=dotted]; 74 -> {75} [style=dotted]; 75 -> {76} [style=dotted]; - 75 -> {99} [style=dotted] [label=onUncaughtException]; 76 -> {77} [style=dotted]; + 76 -> {100} [style=dotted] [label=onUncaughtException]; 77 -> {78} [style=dotted]; - 78 -> {80 79} [style=dotted]; - 79 -> {86} [style=dotted]; - 80 -> {81} [style=dotted]; + 78 -> {79} [style=dotted]; + 79 -> {81 80} [style=dotted]; + 80 -> {87} [style=dotted]; 81 -> {82} [style=dotted]; - 82 -> {89 83} [style=dotted]; - 83 -> {84} [style=dotted]; + 82 -> {83} [style=dotted]; + 83 -> {90 84} [style=dotted]; 84 -> {85} [style=dotted]; 85 -> {86} [style=dotted]; 86 -> {87} [style=dotted]; 87 -> {88} [style=dotted]; - 88 -> {60} [color=green style=dotted]; - 89 -> {90}; + 88 -> {89} [style=dotted]; + 89 -> {61} [color=green style=dotted]; 90 -> {91}; - 91 -> {92 97}; - 92 -> {93}; - 93 -> {100}; - 93 -> {95} [color=red]; - 93 -> {100} [style=dashed]; + 91 -> {92}; + 92 -> {93 98}; + 93 -> {94}; + 94 -> {101}; 94 -> {96} [color=red]; - 95 -> {96} [color=green]; - 96 -> {97}; + 94 -> {101} [style=dashed]; + 95 -> {97} [color=red]; + 96 -> {97} [color=green]; 97 -> {98}; 98 -> {99}; - 100 -> {101}; + 99 -> {100}; 101 -> {102}; 102 -> {103}; 103 -> {104}; 104 -> {105}; - 105 -> {94} [color=red]; - 105 -> {95} [color=green]; + 105 -> {106}; + 106 -> {95} [color=red]; + 106 -> {96} [color=green]; } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/referenceToJavaStdlib.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/referenceToJavaStdlib.kt index 1c6ebf46b09..ef4242b2f99 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/referenceToJavaStdlib.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/referenceToJavaStdlib.kt @@ -7,7 +7,7 @@ import java.nio.file.Files fun detectDirsWithTestsMapFileOnly(file: File): List { Files.walk(file.toPath()).filter(Files::isRegularFile) -} +} interface A fun foo(x: A, vararg strings: String) {} diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/sam.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/sam.kt index cd8dd27cdb1..3d4f803c20f 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/sam.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/sam.kt @@ -3,7 +3,7 @@ fun interface MySam { } class A { - fun bar(x: String): Int {} + fun bar(x: String): Int {} } fun foo(x: MySam) {} diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/simpleClassReceiver.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/simpleClassReceiver.kt index a900eca189c..78640665440 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/simpleClassReceiver.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/simpleClassReceiver.kt @@ -1,5 +1,5 @@ class A { - fun bar(x: String): Int {} + fun bar(x: String): Int {} } fun foo(x: (A, String) -> Int) {} diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/simpleExpressionReceiver.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/simpleExpressionReceiver.kt index 9f0ff9a3207..a97f8b3eb20 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/simpleExpressionReceiver.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/simpleExpressionReceiver.kt @@ -1,5 +1,5 @@ class A { - fun bar(x: String): Int {} + fun bar(x: String): Int {} } fun foo(x: (String) -> Int) {} diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/simpleNoReceiver.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/simpleNoReceiver.kt index 98c61c00fdb..14bd5a6ff37 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/simpleNoReceiver.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/simpleNoReceiver.kt @@ -1,6 +1,6 @@ fun foo(x: (String) -> Int) {} -fun bar(x: String): Int {} +fun bar(x: String): Int {} fun main() { foo(::bar) diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateWithAnonymousObject.dot b/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateWithAnonymousObject.dot index e456129cfe8..623a6c7d80e 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateWithAnonymousObject.dot +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateWithAnonymousObject.dot @@ -27,223 +27,225 @@ digraph delegateWithAnonymousObject_kt { 6 [label="Enter block"]; 7 [label="Const: Null(null)"]; 8 [label="Check not null: Null(null)!!"]; - 9 [label="Jump: ^delegate Null(null)!!"]; - 10 [label="Stub" style="filled" fillcolor=gray]; - 11 [label="Exit block" style="filled" fillcolor=gray]; + 9 [label="Stub" style="filled" fillcolor=gray]; + 10 [label="Jump: ^delegate Null(null)!!" style="filled" fillcolor=gray]; + 11 [label="Stub" style="filled" fillcolor=gray]; + 12 [label="Exit block" style="filled" fillcolor=gray]; } - 12 [label="Exit function delegate" style="filled" fillcolor=red]; + 13 [label="Exit function delegate" style="filled" fillcolor=red]; } 5 -> {6}; 6 -> {7}; 7 -> {8}; - 8 -> {9}; - 9 -> {12}; + 8 -> {13} [label=onUncaughtException]; + 8 -> {9} [style=dotted]; 9 -> {10} [style=dotted]; - 10 -> {11} [style=dotted]; + 10 -> {13 11} [style=dotted]; 11 -> {12} [style=dotted]; + 12 -> {13} [style=dotted]; subgraph cluster_4 { color=red - 13 [label="Enter function " style="filled" fillcolor=red]; - 14 [label="Delegated constructor call: super|>()"]; - 15 [label="Exit function " style="filled" fillcolor=red]; + 14 [label="Enter function " style="filled" fillcolor=red]; + 15 [label="Delegated constructor call: super|>()"]; + 16 [label="Exit function " style="filled" fillcolor=red]; } - 13 -> {14}; 14 -> {15}; + 15 -> {16}; subgraph cluster_5 { color=red - 16 [label="Enter function updateFrom" style="filled" fillcolor=red]; + 17 [label="Enter function updateFrom" style="filled" fillcolor=red]; subgraph cluster_6 { color=blue - 17 [label="Enter block"]; - 18 [label="Exit block"]; + 18 [label="Enter block"]; + 19 [label="Exit block"]; } - 19 [label="Exit function updateFrom" style="filled" fillcolor=red]; + 20 [label="Exit function updateFrom" style="filled" fillcolor=red]; } - 16 -> {17}; 17 -> {18}; 18 -> {19}; + 19 -> {20}; subgraph cluster_7 { color=red - 20 [label="Enter class IssueListView" style="filled" fillcolor=red]; - 21 [label="Exit class IssueListView" style="filled" fillcolor=red]; + 21 [label="Enter class IssueListView" style="filled" fillcolor=red]; + 22 [label="Exit class IssueListView" style="filled" fillcolor=red]; } - 20 -> {21} [color=green]; + 21 -> {22} [color=green]; subgraph cluster_8 { color=red - 22 [label="Enter function " style="filled" fillcolor=red]; - 23 [label="Delegated constructor call: super|>()"]; - 24 [label="Exit function " style="filled" fillcolor=red]; + 23 [label="Enter function " style="filled" fillcolor=red]; + 24 [label="Delegated constructor call: super|>()"]; + 25 [label="Exit function " style="filled" fillcolor=red]; } - 22 -> {23}; 23 -> {24}; + 24 -> {25}; subgraph cluster_9 { color=red - 33 [label="Enter function " style="filled" fillcolor=red]; - 34 [label="Delegated constructor call: super()"]; - 35 [label="Exit function " style="filled" fillcolor=red]; + 34 [label="Enter function " style="filled" fillcolor=red]; + 35 [label="Delegated constructor call: super()"]; + 36 [label="Exit function " style="filled" fillcolor=red]; } - 33 -> {34}; 34 -> {35}; + 35 -> {36}; subgraph cluster_10 { color=red - 36 [label="Enter function getValue" style="filled" fillcolor=red]; + 37 [label="Enter function getValue" style="filled" fillcolor=red]; subgraph cluster_11 { color=blue - 37 [label="Enter block"]; - 38 [label="Function call: R|/IssueListView.IssueListView|()"]; - 39 [label="Jump: ^getValue R|/IssueListView.IssueListView|()"]; - 40 [label="Stub" style="filled" fillcolor=gray]; - 41 [label="Exit block" style="filled" fillcolor=gray]; + 38 [label="Enter block"]; + 39 [label="Function call: R|/IssueListView.IssueListView|()"]; + 40 [label="Jump: ^getValue R|/IssueListView.IssueListView|()"]; + 41 [label="Stub" style="filled" fillcolor=gray]; + 42 [label="Exit block" style="filled" fillcolor=gray]; } - 42 [label="Exit function getValue" style="filled" fillcolor=red]; + 43 [label="Exit function getValue" style="filled" fillcolor=red]; } - 36 -> {37}; 37 -> {38}; 38 -> {39}; - 39 -> {42}; - 39 -> {40} [style=dotted]; + 39 -> {40}; + 40 -> {43}; 40 -> {41} [style=dotted]; 41 -> {42} [style=dotted]; + 42 -> {43} [style=dotted]; subgraph cluster_12 { color=red - 43 [label="Enter function setValue" style="filled" fillcolor=red]; + 44 [label="Enter function setValue" style="filled" fillcolor=red]; subgraph cluster_13 { color=blue - 44 [label="Enter block"]; - 45 [label="Function call: R|/IssueListView.IssueListView|()"]; - 46 [label="Access variable R|/value|"]; - 47 [label="Function call: R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(...)"]; - 48 [label="Jump: ^setValue R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(R|/value|)"]; - 49 [label="Stub" style="filled" fillcolor=gray]; - 50 [label="Exit block" style="filled" fillcolor=gray]; + 45 [label="Enter block"]; + 46 [label="Function call: R|/IssueListView.IssueListView|()"]; + 47 [label="Access variable R|/value|"]; + 48 [label="Function call: R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(...)"]; + 49 [label="Jump: ^setValue R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(R|/value|)"]; + 50 [label="Stub" style="filled" fillcolor=gray]; + 51 [label="Exit block" style="filled" fillcolor=gray]; } - 51 [label="Exit function setValue" style="filled" fillcolor=red]; + 52 [label="Exit function setValue" style="filled" fillcolor=red]; } - 43 -> {44}; 44 -> {45}; 45 -> {46}; 46 -> {47}; 47 -> {48}; - 48 -> {51}; - 48 -> {49} [style=dotted]; + 48 -> {49}; + 49 -> {52}; 49 -> {50} [style=dotted]; 50 -> {51} [style=dotted]; + 51 -> {52} [style=dotted]; subgraph cluster_14 { color=red - 52 [label="Enter function getter" style="filled" fillcolor=red]; + 53 [label="Enter function getter" style="filled" fillcolor=red]; subgraph cluster_15 { color=blue - 53 [label="Enter block"]; - 54 [label="Access variable D|/IssuesListUserProfile.issueListView|"]; - 55 [label="Access variable this@R|/IssuesListUserProfile|"]; - 56 [label="Function call: this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|SubstitutionOverride|(...)"]; - 57 [label="Jump: ^ this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|SubstitutionOverride|(this@R|/IssuesListUserProfile|, ::R|/IssuesListUserProfile.issueListView|)"]; - 58 [label="Stub" style="filled" fillcolor=gray]; - 59 [label="Exit block" style="filled" fillcolor=gray]; + 54 [label="Enter block"]; + 55 [label="Access variable D|/IssuesListUserProfile.issueListView|"]; + 56 [label="Access variable this@R|/IssuesListUserProfile|"]; + 57 [label="Function call: this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|SubstitutionOverride|(...)"]; + 58 [label="Jump: ^ this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|SubstitutionOverride|(this@R|/IssuesListUserProfile|, ::R|/IssuesListUserProfile.issueListView|)"]; + 59 [label="Stub" style="filled" fillcolor=gray]; + 60 [label="Exit block" style="filled" fillcolor=gray]; } - 60 [label="Exit function getter" style="filled" fillcolor=red]; + 61 [label="Exit function getter" style="filled" fillcolor=red]; } - 52 -> {53}; 53 -> {54}; 54 -> {55}; 55 -> {56}; 56 -> {57}; - 57 -> {60}; - 57 -> {58} [style=dotted]; + 57 -> {58}; + 58 -> {61}; 58 -> {59} [style=dotted]; 59 -> {60} [style=dotted]; + 60 -> {61} [style=dotted]; subgraph cluster_16 { color=red - 61 [label="Enter function setter" style="filled" fillcolor=red]; + 62 [label="Enter function setter" style="filled" fillcolor=red]; subgraph cluster_17 { color=blue - 62 [label="Enter block"]; - 63 [label="Access variable D|/IssuesListUserProfile.issueListView|"]; - 64 [label="Access variable this@R|/IssuesListUserProfile|"]; - 65 [label="Access variable R|/issueListView|"]; - 66 [label="Function call: this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|SubstitutionOverride|(...)"]; - 67 [label="Exit block"]; + 63 [label="Enter block"]; + 64 [label="Access variable D|/IssuesListUserProfile.issueListView|"]; + 65 [label="Access variable this@R|/IssuesListUserProfile|"]; + 66 [label="Access variable R|/issueListView|"]; + 67 [label="Function call: this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|SubstitutionOverride|(...)"]; + 68 [label="Exit block"]; } - 68 [label="Exit function setter" style="filled" fillcolor=red]; + 69 [label="Exit function setter" style="filled" fillcolor=red]; } - 61 -> {62}; 62 -> {63}; 63 -> {64}; 64 -> {65}; 65 -> {66}; 66 -> {67}; 67 -> {68}; + 68 -> {69}; subgraph cluster_18 { color=red - 69 [label="Enter property" style="filled" fillcolor=red]; - 70 [label="Postponed enter to lambda"]; - 71 [label="Postponed exit from lambda"]; - 72 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|(...)"]; - 73 [label="Access variable this@R|/IssuesListUserProfile|"]; - 74 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|(...).#(...)"]; - 75 [label="Postponed enter to lambda"]; + 70 [label="Enter property" style="filled" fillcolor=red]; + 71 [label="Postponed enter to lambda"]; + 72 [label="Postponed exit from lambda"]; + 73 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|(...)"]; + 74 [label="Access variable this@R|/IssuesListUserProfile|"]; + 75 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|(...).#(...)"]; + 76 [label="Postponed enter to lambda"]; subgraph cluster_19 { color=blue - 25 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 26 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; subgraph cluster_20 { color=blue - 26 [label="Enter block"]; - 27 [label="Exit anonymous object"]; - 28 [label="Exit anonymous object expression"]; - 29 [label="Exit block"]; + 27 [label="Enter block"]; + 28 [label="Exit anonymous object"]; + 29 [label="Exit anonymous object expression"]; + 30 [label="Exit block"]; } - 30 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 31 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } subgraph cluster_21 { color=blue - 31 [label="Enter class " style="filled" fillcolor=red]; - 32 [label="Exit class " style="filled" fillcolor=red]; + 32 [label="Enter class " style="filled" fillcolor=red]; + 33 [label="Exit class " style="filled" fillcolor=red]; } - 76 [label="Postponed exit from lambda"]; - 77 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|(...)"]; - 78 [label="Exit property" style="filled" fillcolor=red]; + 77 [label="Postponed exit from lambda"]; + 78 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|(...)"]; + 79 [label="Exit property" style="filled" fillcolor=red]; } - 69 -> {70}; 70 -> {71}; - 70 -> {} [style=dashed]; 71 -> {72}; + 71 -> {} [style=dashed]; 72 -> {73}; 73 -> {74}; 74 -> {75}; - 75 -> {76 25}; - 75 -> {25} [style=dashed]; - 76 -> {77}; + 75 -> {76}; + 76 -> {77 26}; + 76 -> {26} [style=dashed]; 77 -> {78}; - 78 -> {81} [color=green]; - 25 -> {26}; + 78 -> {79}; + 79 -> {82} [color=green]; 26 -> {27}; - 26 -> {33 36 43} [color=red]; 27 -> {28}; - 27 -> {33 36 43 31} [color=green]; - 27 -> {33 36 43 31} [style=dashed]; + 27 -> {34 37 44} [color=red]; 28 -> {29}; + 28 -> {34 37 44 32} [color=green]; + 28 -> {34 37 44 32} [style=dashed]; 29 -> {30}; - 31 -> {32} [color=green]; + 30 -> {31}; + 32 -> {33} [color=green]; subgraph cluster_22 { color=red - 79 [label="Enter class IssuesListUserProfile" style="filled" fillcolor=red]; - 80 [label="Part of class initialization"]; - 81 [label="Exit class IssuesListUserProfile" style="filled" fillcolor=red]; + 80 [label="Enter class IssuesListUserProfile" style="filled" fillcolor=red]; + 81 [label="Part of class initialization"]; + 82 [label="Exit class IssuesListUserProfile" style="filled" fillcolor=red]; } - 79 -> {80} [color=green]; - 80 -> {81} [style=dotted]; - 80 -> {69} [color=green]; - 80 -> {69} [style=dashed]; + 80 -> {81} [color=green]; + 81 -> {82} [style=dotted]; + 81 -> {70} [color=green]; + 81 -> {70} [style=dashed]; } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.dot b/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.dot index 5416aeee98d..cc5d000b16c 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.dot +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.dot @@ -11,151 +11,153 @@ digraph plusAssignWithLambdaInRhs_kt { 1 [label="Enter block"]; 2 [label="Const: Null(null)"]; 3 [label="Check not null: Null(null)!!"]; - 4 [label="Variable declaration: lval list: R|kotlin/collections/MutableList>|"]; - 5 [label="Access variable R|/list|"]; - 6 [label="Postponed enter to lambda"]; + 4 [label="Stub" style="filled" fillcolor=gray]; + 5 [label="Variable declaration: lval list: R|kotlin/collections/MutableList>|" style="filled" fillcolor=gray]; + 6 [label="Access variable R|/list|" style="filled" fillcolor=gray]; + 7 [label="Postponed enter to lambda" style="filled" fillcolor=gray]; subgraph cluster_2 { color=blue - 11 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 12 [label="Enter function anonymousFunction" style="filled" fillcolor=red style="filled" fillcolor=gray]; subgraph cluster_3 { color=blue - 12 [label="Enter block"]; - 13 [label="Access variable R|/it|"]; - 14 [label="Exit block"]; + 13 [label="Enter block" style="filled" fillcolor=gray]; + 14 [label="Access variable R|/it|" style="filled" fillcolor=gray]; + 15 [label="Exit block" style="filled" fillcolor=gray]; } - 15 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 16 [label="Exit function anonymousFunction" style="filled" fillcolor=red style="filled" fillcolor=gray]; } - 7 [label="Postponed exit from lambda"]; - 8 [label="Function call: R|/list|.R|kotlin/collections/plusAssign| kotlin/String|>(...)"]; - 9 [label="Exit block"]; + 8 [label="Postponed exit from lambda" style="filled" fillcolor=gray]; + 9 [label="Function call: R|/list|.R|kotlin/collections/plusAssign| kotlin/String|>(...)" style="filled" fillcolor=gray]; + 10 [label="Exit block" style="filled" fillcolor=gray]; } - 10 [label="Exit function test" style="filled" fillcolor=red]; + 11 [label="Exit function test" style="filled" fillcolor=red]; } 0 -> {1}; 1 -> {2}; 2 -> {3}; - 3 -> {4}; - 4 -> {5}; - 5 -> {6}; - 6 -> {11}; - 6 -> {7} [color=red]; - 6 -> {11} [style=dashed]; - 7 -> {8}; - 8 -> {9}; - 9 -> {10}; - 11 -> {15 12}; - 12 -> {13}; - 13 -> {14}; - 14 -> {15}; - 15 -> {7} [color=green]; - 15 -> {11} [color=green style=dashed]; + 3 -> {11} [label=onUncaughtException]; + 3 -> {4} [style=dotted]; + 4 -> {5} [style=dotted]; + 5 -> {6} [style=dotted]; + 6 -> {7} [style=dotted]; + 7 -> {8 12} [style=dotted]; + 7 -> {12} [style=dashed]; + 8 -> {9} [style=dotted]; + 9 -> {10} [style=dotted]; + 10 -> {11} [style=dotted]; + 12 -> {16 13} [style=dotted]; + 13 -> {14} [style=dotted]; + 14 -> {15} [style=dotted]; + 15 -> {16} [style=dotted]; + 16 -> {8} [style=dotted]; + 16 -> {12} [color=green style=dotted]; subgraph cluster_4 { color=red - 16 [label="Enter function " style="filled" fillcolor=red]; - 17 [label="Delegated constructor call: super()"]; - 18 [label="Exit function " style="filled" fillcolor=red]; + 17 [label="Enter function " style="filled" fillcolor=red]; + 18 [label="Delegated constructor call: super()"]; + 19 [label="Exit function " style="filled" fillcolor=red]; } - 16 -> {17}; 17 -> {18}; + 18 -> {19}; subgraph cluster_5 { color=red - 19 [label="Enter property" style="filled" fillcolor=red]; - 20 [label="Access variable R|/executor|"]; - 21 [label="Exit property" style="filled" fillcolor=red]; + 20 [label="Enter property" style="filled" fillcolor=red]; + 21 [label="Access variable R|/executor|"]; + 22 [label="Exit property" style="filled" fillcolor=red]; } - 19 -> {20}; 20 -> {21}; - 21 -> {24} [color=green]; + 21 -> {22}; + 22 -> {25} [color=green]; subgraph cluster_6 { color=red - 22 [label="Enter class A" style="filled" fillcolor=red]; - 23 [label="Part of class initialization"]; - 24 [label="Exit class A" style="filled" fillcolor=red]; + 23 [label="Enter class A" style="filled" fillcolor=red]; + 24 [label="Part of class initialization"]; + 25 [label="Exit class A" style="filled" fillcolor=red]; } - 22 -> {23} [color=green]; - 23 -> {24} [style=dotted]; - 23 -> {19} [color=green]; - 23 -> {19} [style=dashed]; + 23 -> {24} [color=green]; + 24 -> {25} [style=dotted]; + 24 -> {20} [color=green]; + 24 -> {20} [style=dashed]; subgraph cluster_7 { color=red - 25 [label="Enter function postpone" style="filled" fillcolor=red]; + 26 [label="Enter function postpone" style="filled" fillcolor=red]; subgraph cluster_8 { color=blue - 26 [label="Enter block"]; - 27 [label="Function call: R|kotlin/collections/mutableListOf| kotlin/Unit|>()"]; - 28 [label="Variable declaration: lval queue: R|kotlin/collections/MutableList>|"]; - 29 [label="Postponed enter to lambda"]; + 27 [label="Enter block"]; + 28 [label="Function call: R|kotlin/collections/mutableListOf| kotlin/Unit|>()"]; + 29 [label="Variable declaration: lval queue: R|kotlin/collections/MutableList>|"]; + 30 [label="Postponed enter to lambda"]; subgraph cluster_9 { color=blue - 36 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 37 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; subgraph cluster_10 { color=blue - 37 [label="Enter block"]; - 38 [label="Access variable R|/queue|"]; - 39 [label="Postponed enter to lambda"]; + 38 [label="Enter block"]; + 39 [label="Access variable R|/queue|"]; + 40 [label="Postponed enter to lambda"]; subgraph cluster_11 { color=blue - 44 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 45 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; subgraph cluster_12 { color=blue - 45 [label="Enter block"]; - 46 [label="Function call: R|/computation|.R|SubstitutionOverride|()"]; - 47 [label="Function call: R|/resolve|.R|SubstitutionOverride|(...)"]; - 48 [label="Exit block"]; + 46 [label="Enter block"]; + 47 [label="Function call: R|/computation|.R|SubstitutionOverride|()"]; + 48 [label="Function call: R|/resolve|.R|SubstitutionOverride|(...)"]; + 49 [label="Exit block"]; } - 49 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 50 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 40 [label="Postponed exit from lambda"]; - 41 [label="Function call: R|/queue|.R|kotlin/collections/plusAssign| kotlin/Unit|>(...)"]; - 42 [label="Exit block"]; + 41 [label="Postponed exit from lambda"]; + 42 [label="Function call: R|/queue|.R|kotlin/collections/plusAssign| kotlin/Unit|>(...)"]; + 43 [label="Exit block"]; } - 43 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + 44 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } - 30 [label="Postponed exit from lambda"]; - 31 [label="Function call: R|/A.A|(...)"]; - 32 [label="Jump: ^postpone R|/A.A|( = A@fun (resolve: R|(T) -> kotlin/Unit|): R|kotlin/Unit| { + 31 [label="Postponed exit from lambda"]; + 32 [label="Function call: R|/A.A|(...)"]; + 33 [label="Jump: ^postpone R|/A.A|( = A@fun (resolve: R|(T) -> kotlin/Unit|): R|kotlin/Unit| { R|/queue|.R|kotlin/collections/plusAssign| kotlin/Unit|>(A@fun (): R|kotlin/Unit| { R|/resolve|.R|SubstitutionOverride|(R|/computation|.R|SubstitutionOverride|()) } ) } )"]; - 33 [label="Stub" style="filled" fillcolor=gray]; - 34 [label="Exit block" style="filled" fillcolor=gray]; + 34 [label="Stub" style="filled" fillcolor=gray]; + 35 [label="Exit block" style="filled" fillcolor=gray]; } - 35 [label="Exit function postpone" style="filled" fillcolor=red]; + 36 [label="Exit function postpone" style="filled" fillcolor=red]; } - 25 -> {26}; 26 -> {27}; 27 -> {28}; 28 -> {29}; - 29 -> {30 36}; - 29 -> {36} [style=dashed]; - 30 -> {31}; + 29 -> {30}; + 30 -> {31 37}; + 30 -> {37} [style=dashed]; 31 -> {32}; - 32 -> {35}; - 32 -> {33} [style=dotted]; + 32 -> {33}; + 33 -> {36}; 33 -> {34} [style=dotted]; 34 -> {35} [style=dotted]; - 36 -> {37}; + 35 -> {36} [style=dotted]; 37 -> {38}; 38 -> {39}; - 39 -> {44}; - 39 -> {40} [color=red]; - 39 -> {44} [style=dashed]; - 40 -> {41}; + 39 -> {40}; + 40 -> {45}; + 40 -> {41} [color=red]; + 40 -> {45} [style=dashed]; 41 -> {42}; 42 -> {43}; - 44 -> {49 45}; - 45 -> {46}; + 43 -> {44}; + 45 -> {50 46}; 46 -> {47}; 47 -> {48}; 48 -> {49}; - 49 -> {40} [color=green]; - 49 -> {44} [color=green style=dashed]; + 49 -> {50}; + 50 -> {41} [color=green]; + 50 -> {45} [color=green style=dashed]; } diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt index c2d91c82f94..de96d0b26c2 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt @@ -1036,6 +1036,7 @@ object DIAGNOSTICS_LIST : DiagnosticList("FirErrors") { val RETURNS by object : DiagnosticGroup("Returns") { val RETURN_NOT_ALLOWED by error(PositioningStrategy.RETURN_WITH_LABEL) val RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY by error(PositioningStrategy.RETURN_WITH_LABEL) + val NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY by error(PositioningStrategy.DECLARATION_WITH_BODY) } val INLINE by object : DiagnosticGroup("Inline") { diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/model/DiagnosticData.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/model/DiagnosticData.kt index 0fd2b85350b..7d4a5ad5291 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/model/DiagnosticData.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/model/DiagnosticData.kt @@ -76,6 +76,7 @@ enum class PositioningStrategy(private val strategy: String? = null) { IMPORT_LAST_NAME, DATA_MODIFIER, SPREAD_OPERATOR, + DECLARATION_WITH_BODY, ; diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index 3e02df8d04a..9a7eeb5ba51 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -41,6 +41,7 @@ import org.jetbrains.kotlin.psi.KtCallExpression import org.jetbrains.kotlin.psi.KtClass import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtDeclaration +import org.jetbrains.kotlin.psi.KtDeclarationWithBody import org.jetbrains.kotlin.psi.KtDestructuringDeclaration import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtExpression @@ -546,6 +547,7 @@ object FirErrors { // Returns val RETURN_NOT_ALLOWED by error0(SourceElementPositioningStrategies.RETURN_WITH_LABEL) val RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY by error0(SourceElementPositioningStrategies.RETURN_WITH_LABEL) + val NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY by error0(SourceElementPositioningStrategies.DECLARATION_WITH_BODY) // Inline val USAGE_IS_NOT_INLINABLE by error1>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/CommonDeclarationCheckers.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/CommonDeclarationCheckers.kt index 133bfab4f7a..12636814870 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/CommonDeclarationCheckers.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/CommonDeclarationCheckers.kt @@ -36,7 +36,8 @@ object CommonDeclarationCheckers : DeclarationCheckers() { get() = setOf( FirContractChecker, FirFunctionParameterChecker, - FirInlineDeclarationChecker + FirInlineDeclarationChecker, + FirFunctionReturnChecker, ) override val simpleFunctionCheckers: Set diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirFunctionReturnChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirFunctionReturnChecker.kt new file mode 100644 index 00000000000..3e2962501c6 --- /dev/null +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirFunctionReturnChecker.kt @@ -0,0 +1,41 @@ +/* + * Copyright 2010-2021 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.analysis.checkers.declaration + +import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors +import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn +import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.utils.hasBody +import org.jetbrains.kotlin.fir.resolve.dfa.cfg.BlockExitNode +import org.jetbrains.kotlin.fir.resolve.dfa.controlFlowGraph +import org.jetbrains.kotlin.fir.types.isNothing +import org.jetbrains.kotlin.fir.types.isUnit + +object FirFunctionReturnChecker : FirFunctionChecker() { + + override fun check(declaration: FirFunction, context: CheckerContext, reporter: DiagnosticReporter) { + checkHasReturnIfBlock(declaration, reporter, context) + } + + private fun checkHasReturnIfBlock( + declaration: FirFunction, + reporter: DiagnosticReporter, + context: CheckerContext + ) { + if (declaration is FirPropertyAccessor && declaration.isSetter) return + if (declaration is FirConstructor) return + if (declaration is FirAnonymousFunction && declaration.isLambda) return + if (declaration.returnTypeRef.isUnit || declaration.returnTypeRef.isNothing) return + val graph = declaration.controlFlowGraphReference?.controlFlowGraph ?: return + + val blockExitNode = graph.exitNode.previousNodes.lastOrNull { it is BlockExitNode } ?: return + if (!blockExitNode.isDead) { + reporter.reportOn(declaration.source, FirErrors.NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY, context) + } + } +} \ No newline at end of file diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirPropertyAccessorChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirPropertyAccessorChecker.kt index df4b91b8bd7..f82d33e93d8 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirPropertyAccessorChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirPropertyAccessorChecker.kt @@ -56,6 +56,7 @@ object FirPropertyAccessorsTypesChecker : FirPropertyChecker() { reporter.reportOn(getterReturnTypeSource, FirErrors.WRONG_GETTER_RETURN_TYPE, propertyType, getterReturnType, context) } } +// FirFunctionReturnChecker.checkHasReturnIfBlock(getter, reporter, context) } } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt index 7e08b6b08c9..aadd39e773a 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt @@ -247,6 +247,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NOT_NULL_ASSERTIO import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NO_COMPANION_OBJECT import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NO_ELSE_IN_WHEN import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NO_GET_METHOD +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NO_SET_METHOD import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NO_THIS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NO_VALUE_FOR_PARAMETER @@ -814,6 +815,8 @@ class FirDefaultErrorMessages { map.put(TYPE_PARAMETER_OF_PROPERTY_NOT_USED_IN_RECEIVER, "Type parameter of a property must be used in its receiver type") + map.put(NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY, "A 'return' expression required in a function with a block body ('{...}')") + map.put(RETURN_TYPE_MISMATCH, "Return type mismatch: expected {0}, actual {1}", RENDER_TYPE, RENDER_TYPE, NOT_RENDERED) map.put(CYCLIC_GENERIC_UPPER_BOUND, "Type parameter has cyclic upper bounds") diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt index 4e85ecb47b5..347df422052 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt @@ -793,6 +793,29 @@ object LightTreePositioningStrategies { return super.mark(node, startOffset, startOffset + 1, tree) } } + + val DECLARATION_WITH_BODY: LightTreePositioningStrategy = object : LightTreePositioningStrategy() { + override fun mark( + node: LighterASTNode, + startOffset: Int, + endOffset: Int, + tree: FlyweightCapableTreeStructure + ): List { + val blockNode = + if (node.tokenType != KtNodeTypes.BLOCK) tree.findChildByType(node, KtNodeTypes.BLOCK) + else node + val bracket = tree.findLastChildByType(blockNode ?: node, KtTokens.RBRACE) + return when { + bracket != null -> markElement(bracket, startOffset, endOffset, tree, node) + blockNode != null -> markElement(blockNode, startOffset, endOffset, tree, node).map(::lastSymbol) + else -> super.mark(node, startOffset, endOffset, tree) + } + } + + //body of block node is in the separate tree, so here is hack - mark last symbol of block + private fun lastSymbol(range: TextRange): TextRange = + if (range.isEmpty) range else TextRange.create(range.endOffset - 1, range.endOffset) + } } fun FirSourceElement.hasValOrVar(): Boolean = diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt index 7ba595b2d93..0a437dcd6ff 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt @@ -267,4 +267,9 @@ object SourceElementPositioningStrategies { LightTreePositioningStrategies.SPREAD_OPERATOR, PositioningStrategies.SPREAD_OPERATOR ) + + val DECLARATION_WITH_BODY = SourceElementPositioningStrategy( + LightTreePositioningStrategies.DECLARATION_WITH_BODY, + PositioningStrategies.DECLARATION_WITH_BODY + ) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt index b600ca5393e..8096552516f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt @@ -135,7 +135,8 @@ class ControlFlowGraphBuilder { fun CFGNode<*>.extractArgument(): FirElement? = when (this) { is FunctionEnterNode, is TryMainBlockEnterNode, is FinallyBlockExitNode, is CatchClauseEnterNode -> null - is StubNode, is BlockExitNode -> firstPreviousNode.extractArgument() + is BlockExitNode -> if (function.isLambda || isDead) firstPreviousNode.extractArgument() else null + is StubNode -> firstPreviousNode.extractArgument() else -> fir.extractArgument() } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt index 3094ed8e3c8..cf26a08efe2 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt @@ -562,10 +562,16 @@ class FirCallCompletionResultsWriterTransformer( } val initialType = anonymousFunction.returnTypeRef.coneTypeSafe() - val finalType = + + val finalType = if (anonymousFunction.isLambda) { expectedType?.returnType(session) as? ConeClassLikeType ?: (data as? ExpectedArgumentType.ArgumentsMap)?.lambdasReturnTypes?.get(anonymousFunction) ?: initialType?.let(finalSubstitutor::substituteOrSelf) + } else { + initialType?.let(finalSubstitutor::substituteOrSelf) + ?: expectedType?.returnType(session) as? ConeClassLikeType + ?: (data as? ExpectedArgumentType.ArgumentsMap)?.lambdasReturnTypes?.get(anonymousFunction) + } if (finalType != null) { val resultType = anonymousFunction.returnTypeRef.withReplacedConeType(finalType) diff --git a/compiler/testData/diagnostics/tests/FunctionReturnTypes.fir.kt b/compiler/testData/diagnostics/tests/FunctionReturnTypes.fir.kt index e2a946d630d..610aebd5baf 100644 --- a/compiler/testData/diagnostics/tests/FunctionReturnTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/FunctionReturnTypes.fir.kt @@ -31,12 +31,12 @@ fun unitShort() : Unit = Unit fun unitShortConv() : Unit = 1 fun unitShortNull() : Unit = null -fun intEmpty() : Int {} +fun intEmpty() : Int {} fun intShortInfer() = 1 fun intShort() : Int = 1 //fun intBlockInfer() {1} fun intBlock() : Int {return 1} -fun intBlock1() : Int {1} +fun intBlock1() : Int {1} fun intString(): Int = "s" fun intFunctionLiteral(): Int = { 10 } @@ -48,7 +48,7 @@ fun blockReturnValueTypeMismatchUnit() : Int {return Uni fun blockAndAndMismatch() : Int { true && false - } + } fun blockAndAndMismatch1() : Int { return true && false } @@ -58,7 +58,7 @@ fun blockAndAndMismatch2() : Int { fun blockAndAndMismatch3() : Int { true || false - } + } fun blockAndAndMismatch4() : Int { return true || false } @@ -93,7 +93,7 @@ fun blockReturnValueTypeMatch7() : Int { if (1 > 2) 1.0 else 2.0 - } + } fun blockReturnValueTypeMatch8() : Int { if (1 > 2) 1.0 @@ -103,7 +103,7 @@ fun blockReturnValueTypeMatch8() : Int { fun blockReturnValueTypeMatch9() : Int { if (1 > 2) 1.0 - } + } fun blockReturnValueTypeMatch10() : Int { return if (1 > 2) 1 @@ -111,7 +111,7 @@ fun blockReturnValueTypeMatch10() : Int { fun blockReturnValueTypeMatch11() : Int { if (1 > 2) else 1.0 - } + } fun blockReturnValueTypeMatch12() : Int { if (1 > 2) return 1 @@ -119,10 +119,10 @@ fun blockReturnValueTypeMatch12() : Int { } fun blockNoReturnIfValDeclaration(): Int { val x = 1 - } + } fun blockNoReturnIfEmptyIf(): Int { if (1 < 2) {} else {} - } + } fun blockNoReturnIfUnitInOneBranch(): Int { if (1 < 2) { return 1 @@ -132,7 +132,7 @@ fun blockNoReturnIfUnitInOneBranch(): Int { return 2 } } - } + } fun nonBlockReturnIfEmptyIf(): Int = if (1 < 2) {} else {} fun nonBlockNoReturnIfUnitInOneBranch(): Int = if (1 < 2) {} else 2 diff --git a/compiler/testData/diagnostics/tests/OperatorChecks.fir.kt b/compiler/testData/diagnostics/tests/OperatorChecks.fir.kt index 8ee4b02279d..740a20d4346 100644 --- a/compiler/testData/diagnostics/tests/OperatorChecks.fir.kt +++ b/compiler/testData/diagnostics/tests/OperatorChecks.fir.kt @@ -98,33 +98,33 @@ interface Example3 { -operator fun Example.plus(o: Any): Example {} -operator fun Example.div(o: Example): Example {} -operator fun Example.plus(o: Example, s: String = ""): Example {} -operator fun Example.minus(vararg o: Example): Example {} -operator fun Example.plus(): Example {} -operator fun Example.minus(): Example {} +operator fun Example.plus(o: Any): Example {} +operator fun Example.div(o: Example): Example {} +operator fun Example.plus(o: Example, s: String = ""): Example {} +operator fun Example.minus(vararg o: Example): Example {} +operator fun Example.plus(): Example {} +operator fun Example.minus(): Example {} -operator fun Example.unaryPlus(): Example {} -operator fun Example.unaryMinus(): Example {} +operator fun Example.unaryPlus(): Example {} +operator fun Example.unaryMinus(): Example {} -operator fun Example.unaryPlus(s: String = ""): Example {} +operator fun Example.unaryPlus(s: String = ""): Example {} operator fun Example.unaryMinus(o: Example) {} -operator fun Example.inc(): Example {} -operator fun Example.dec(): Example? {} +operator fun Example.inc(): Example {} +operator fun Example.dec(): Example? {} operator fun Example.plusAssign(n: Int) {} -operator fun Example.minusAssign(n: Int): String {} +operator fun Example.minusAssign(n: Int): String {} operator fun Example.divAssign(n: Int, a: String = "") {} operator fun Example.modAssign(vararg n: Int) {} -operator fun Example.compareTo(other: Example): Int {} +operator fun Example.compareTo(other: Example): Int {} -operator fun Example.equals(a: String): Boolean {} +operator fun Example.equals(a: String): Boolean {} -operator fun Example.contains(n: Int): Boolean {} -operator fun Example.contains(n: Int, s: String = ""): Boolean {} +operator fun Example.contains(n: Int): Boolean {} +operator fun Example.contains(n: Int, s: String = ""): Boolean {} operator fun Example.invoke() {} @@ -140,18 +140,18 @@ operator fun Example.rangeTo(o: Int) {} operator fun Example.rangeTo(o: Int, o2: Int) {} operator fun Example.rangeTo(vararg o: String) {} -operator fun Example.component1(): Int {} -operator fun Example.component1(n: Int): Int {} -operator fun Example.componentN(): Int {} +operator fun Example.component1(): Int {} +operator fun Example.component1(n: Int): Int {} +operator fun Example.componentN(): Int {} -operator fun Example.iterator(): String {} -operator fun Example.iterator(n: Int): String {} +operator fun Example.iterator(): String {} +operator fun Example.iterator(n: Int): String {} -operator fun Example.next(): String {} -operator fun Example.next(n: Int): String {} +operator fun Example.next(): String {} +operator fun Example.next(n: Int): String {} -operator fun Example.hasNext(): Boolean {} -operator fun Example.hasNext(n: Int): String {} +operator fun Example.hasNext(): Boolean {} +operator fun Example.hasNext(n: Int): String {} infix fun Example.i1(n: Int) {} infix fun Example.i1(n: Int, n2: Int) {} @@ -161,31 +161,31 @@ infix fun Example.i1(vararg n: Int) {} -operator fun plus(o: String): Example {} -operator fun div(o: Example): Example {} -operator fun plus(o: Example, s: String = ""): Example {} -operator fun minus(vararg o: Example): Example {} +operator fun plus(o: String): Example {} +operator fun div(o: Example): Example {} +operator fun plus(o: Example, s: String = ""): Example {} +operator fun minus(vararg o: Example): Example {} -operator fun unaryPlus(): Example {} -operator fun unaryMinus(): Example {} +operator fun unaryPlus(): Example {} +operator fun unaryMinus(): Example {} -operator fun unaryPlus(s: String = ""): Example {} +operator fun unaryPlus(s: String = ""): Example {} operator fun unaryMinus(o: Example) {} -operator fun inc(): Example {} -operator fun dec(): Example? {} +operator fun inc(): Example {} +operator fun dec(): Example? {} operator fun plusAssign(n: Int) {} -operator fun minusAssign(n: Int): String {} +operator fun minusAssign(n: Int): String {} operator fun divAssign(n: Int, a: String = "") {} operator fun modAssign(vararg n: Int) {} -operator fun compareTo(other: Example): Int {} +operator fun compareTo(other: Example): Int {} -operator fun equals(a: String): Boolean {} +operator fun equals(a: String): Boolean {} -operator fun contains(n: Int): Boolean {} -operator fun contains(n: Int, s: String = ""): Boolean {} +operator fun contains(n: Int): Boolean {} +operator fun contains(n: Int, s: String = ""): Boolean {} operator fun invoke() {} @@ -201,18 +201,18 @@ operator fun rangeTo(o: Int) {} operator fun rangeTo(o: Int, o2: Int) {} operator fun rangeTo(vararg o: String) {} -operator fun component1(): Int {} -operator fun component1(n: Int): Int {} -operator fun componentN(): Int {} +operator fun component1(): Int {} +operator fun component1(n: Int): Int {} +operator fun componentN(): Int {} -operator fun iterator(): String {} -operator fun iterator(n: Int): String {} +operator fun iterator(): String {} +operator fun iterator(n: Int): String {} -operator fun next(): String {} -operator fun next(n: Int): String {} +operator fun next(): String {} +operator fun next(n: Int): String {} -operator fun hasNext(): Boolean {} -operator fun hasNext(n: Int): String {} +operator fun hasNext(): Boolean {} +operator fun hasNext(n: Int): String {} infix fun i1(n: Int) {} infix fun i1(n: Int, n2: Int) {} diff --git a/compiler/testData/diagnostics/tests/TypeInference.fir.kt b/compiler/testData/diagnostics/tests/TypeInference.fir.kt deleted file mode 100644 index 5e7238e0988..00000000000 --- a/compiler/testData/diagnostics/tests/TypeInference.fir.kt +++ /dev/null @@ -1,18 +0,0 @@ -class C() { - fun foo() : T {} -} - -fun foo(c: C) {} -fun bar() : C {} - -fun main() { - val a : C = C(); - val x : C = C() - val y : C = C() - val z : C<*> = C() - - val ba : C = bar(); - val bx : C = bar() - val by : C = bar() - val bz : C<*> = bar() -} diff --git a/compiler/testData/diagnostics/tests/TypeInference.kt b/compiler/testData/diagnostics/tests/TypeInference.kt index c183d978ee3..a39776abe4e 100644 --- a/compiler/testData/diagnostics/tests/TypeInference.kt +++ b/compiler/testData/diagnostics/tests/TypeInference.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL class C() { fun foo() : T {} } diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturn/ReturnFromFunctionInObject.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturn/ReturnFromFunctionInObject.fir.kt deleted file mode 100644 index 3673a7597d9..00000000000 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturn/ReturnFromFunctionInObject.fir.kt +++ /dev/null @@ -1,13 +0,0 @@ -interface X { - fun f(): Boolean -} - -val m = object : X { - override fun f(): Boolean { - } - - fun foo() { - fun local(): Int { - } - } -} diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturn/ReturnFromFunctionInObject.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturn/ReturnFromFunctionInObject.kt index 16948d1b94c..64b499ec473 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturn/ReturnFromFunctionInObject.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturn/ReturnFromFunctionInObject.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL interface X { fun f(): Boolean } diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturn/kt3444_ReturnFromLocalFunctions.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturn/kt3444_ReturnFromLocalFunctions.fir.kt deleted file mode 100644 index 29bcdda8fc7..00000000000 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturn/kt3444_ReturnFromLocalFunctions.fir.kt +++ /dev/null @@ -1,17 +0,0 @@ -package f - - -//KT-3444 Front-end doesn't check if local function or function of anonymous class returns value - -fun box(): Int { - - fun local(): Int { - } - - return local() -} - -fun main() { - box() -} - diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturn/kt3444_ReturnFromLocalFunctions.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturn/kt3444_ReturnFromLocalFunctions.kt index 18dd330ddb8..4b94e6fb713 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturn/kt3444_ReturnFromLocalFunctions.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturn/kt3444_ReturnFromLocalFunctions.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL package f diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturn/simpleClass.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturn/simpleClass.fir.kt index 27fb7bbe48a..86a5ffa4a4d 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturn/simpleClass.fir.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturn/simpleClass.fir.kt @@ -7,10 +7,10 @@ class A {} package test.p; class C {fun f() {}} // FILE: c.kt -package test.p; open class G {open fun f(): T {} fun a() {}} +package test.p; open class G {open fun f(): T {} fun a() {}} // FILE: d.kt -package test.p; class G2 : G { fun g() : E {} override fun f() : E {}} +package test.p; class G2 : G { fun g() : E {} override fun f() : E {}} // FILE: e.kt package test.p; fun foo() {} diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturnInWhen.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturnInWhen.fir.kt index 9a82f54ac4b..166388979d3 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturnInWhen.fir.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturnInWhen.fir.kt @@ -3,4 +3,4 @@ fun illegalWhenBlock(a: Any): Int { is Int -> return a is String -> return a.length } -} +} diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt3444.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt3444.fir.kt deleted file mode 100644 index 6cc325f83bb..00000000000 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt3444.fir.kt +++ /dev/null @@ -1,13 +0,0 @@ -fun box() { - fun local():Int { - } -} - -interface X { - fun f(): Boolean -} - -val m = object : X { - override fun f(): Boolean { - } -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt3444.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt3444.kt index a72db64ced4..b8ac69d0e39 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt3444.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt3444.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL fun box() { fun local():Int { } diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt4405.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt4405.fir.kt index bdbd9ade546..773c6d2846a 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt4405.fir.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt4405.fir.kt @@ -10,19 +10,19 @@ val closure = { } fun h(): Int { // error: should be NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY - } + } } class A { init { fun foo(): Int { - } + } val closure = { val x = "" fun local(): Int { - } + } } val y = "" diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/localClasses.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/localClasses.fir.kt index 775de2d3bb3..5de7433832b 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/localClasses.fir.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/localClasses.fir.kt @@ -7,7 +7,7 @@ fun f() { fun loc1(): Int { val x1_ = "" // ok: unused - } + } } fun f() { @@ -15,12 +15,12 @@ fun f() { fun loc2(): Int { val x2_ = "" // error: should be UNUSED_VARIABLE - } + } } val v: String get() { val x3 = "" // ok: unused - } + } } } diff --git a/compiler/testData/diagnostics/tests/controlStructures/kt786.fir.kt b/compiler/testData/diagnostics/tests/controlStructures/kt786.fir.kt index f8401ff5abc..054625f58d3 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/kt786.fir.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/kt786.fir.kt @@ -9,7 +9,7 @@ fun foo() : Int { else -> { z = -1000 } return z -> 34 } -} +} //test unreachable code fun fff(): Int { diff --git a/compiler/testData/diagnostics/tests/functionLiterals/missedTypeMismatch.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/missedTypeMismatch.fir.kt index 7136e06bb9e..45b31635789 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/missedTypeMismatch.fir.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/missedTypeMismatch.fir.kt @@ -18,13 +18,13 @@ fun main() { val a6: () -> Int = (fun() = 1) val a7: () -> Int = (fun(): String = "1") as () -> Int val a8: () -> Int = fun(): String = "1" - val a9: () -> () -> () -> Int = fun(): () -> () -> String = fun(): () -> String = fun(): String = "1" + val a9: () -> () -> () -> Int = fun(): () -> () -> String = fun(): () -> String = fun(): String = "1" foo(fun(): String = "1") foo(((fun(): String = "1"))) val a10: Int.(String) -> Int = fun (x: String) = 10 - val a11: () -> () -> () -> Int = fun() = fun() = fun(): String = "1" + val a11: () -> () -> () -> Int = fun() = fun() = fun(): String = "1" val a12: Int = fun(): String = "1" val a13: Int = fun() = fun(): String = "1" @@ -34,7 +34,7 @@ fun main() { val a17: () -> Unit = fun() {} val a18: () -> Int = fun() {} - val a19: () -> () -> Int = fun() = fun() {} + val a19: () -> () -> Int = fun() = fun() {} val a20: () -> () -> () -> Unit = fun() = fun() = {} val a21: () -> () -> () -> Int = fun() = fun() = {} } diff --git a/compiler/testData/diagnostics/tests/generics/genericsInType.fir.kt b/compiler/testData/diagnostics/tests/generics/genericsInType.fir.kt index c5da3cbbf0f..be6852f4be5 100644 --- a/compiler/testData/diagnostics/tests/generics/genericsInType.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/genericsInType.fir.kt @@ -33,4 +33,4 @@ fun String.Bar>> x() {} fun Foo.Bar.ext() {} fun ex1(a: Foo.Bar): Foo.Bar { -} +} diff --git a/compiler/testData/diagnostics/tests/incompleteCode/SupertypeOfErrorType.fir.kt b/compiler/testData/diagnostics/tests/incompleteCode/SupertypeOfErrorType.fir.kt index 81c11001f22..4ac96b4967e 100644 --- a/compiler/testData/diagnostics/tests/incompleteCode/SupertypeOfErrorType.fir.kt +++ b/compiler/testData/diagnostics/tests/incompleteCode/SupertypeOfErrorType.fir.kt @@ -21,4 +21,4 @@ fun bar(i: Int, a: U) { } //from standard library -public inline fun comparator(fn: (T,T) -> Int): Comparator {} \ No newline at end of file +public inline fun comparator(fn: (T,T) -> Int): Comparator {} diff --git a/compiler/testData/diagnostics/tests/incompleteCode/checkNothingIsSubtype.fir.kt b/compiler/testData/diagnostics/tests/incompleteCode/checkNothingIsSubtype.fir.kt index 422b9c6c20e..d0d3510e621 100644 --- a/compiler/testData/diagnostics/tests/incompleteCode/checkNothingIsSubtype.fir.kt +++ b/compiler/testData/diagnostics/tests/incompleteCode/checkNothingIsSubtype.fir.kt @@ -3,7 +3,7 @@ package d interface A -fun infer(a: A) : T {} +fun infer(a: A) : T {} fun test(nothing: Nothing?) { val i = infer(nothing) @@ -12,4 +12,4 @@ fun test(nothing: Nothing?) { fun sum(a : IntArray) : Int { for (n return "?" -} +} diff --git a/compiler/testData/diagnostics/tests/incompleteCode/incompleteAssignment.fir.kt b/compiler/testData/diagnostics/tests/incompleteCode/incompleteAssignment.fir.kt index aa121282304..c6ac1ef5c95 100644 --- a/compiler/testData/diagnostics/tests/incompleteCode/incompleteAssignment.fir.kt +++ b/compiler/testData/diagnostics/tests/incompleteCode/incompleteAssignment.fir.kt @@ -1,3 +1,5 @@ +// COMPARE_WITH_LIGHT_TREE + package sum import java.util.* @@ -6,7 +8,7 @@ fun sum(a : IntArray) : Int { res = 0 for (e in a) res += -} +} fun main() { test(0) test(1, 1) @@ -27,4 +29,4 @@ fun assertEquals(actual : T?, expected : T?, message : Any? = null) { else throw AssertionError(message) } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/incompleteCode/incompleteAssignment.kt b/compiler/testData/diagnostics/tests/incompleteCode/incompleteAssignment.kt index 575dd3168f6..bb0d09107f0 100644 --- a/compiler/testData/diagnostics/tests/incompleteCode/incompleteAssignment.kt +++ b/compiler/testData/diagnostics/tests/incompleteCode/incompleteAssignment.kt @@ -1,3 +1,5 @@ +// COMPARE_WITH_LIGHT_TREE + package sum import java.util.* diff --git a/compiler/testData/diagnostics/tests/inference/constraints/definitelyNotNullTypeInReturnPosition.fir.kt b/compiler/testData/diagnostics/tests/inference/constraints/definitelyNotNullTypeInReturnPosition.fir.kt index bd156e137da..7c03187069e 100644 --- a/compiler/testData/diagnostics/tests/inference/constraints/definitelyNotNullTypeInReturnPosition.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/constraints/definitelyNotNullTypeInReturnPosition.fir.kt @@ -268,7 +268,7 @@ class Main(x: L?, y: L) { } fun > nullsLast() = null as Foo -fun take(x: Foo, comparator: Foo): Foo {} +fun take(x: Foo, comparator: Foo): Foo {} fun test() { take(null as Foo, nullsLast()) } diff --git a/compiler/testData/diagnostics/tests/inference/dependantOnVarianceNullable.fir.kt b/compiler/testData/diagnostics/tests/inference/dependantOnVarianceNullable.fir.kt deleted file mode 100644 index f066b72e302..00000000000 --- a/compiler/testData/diagnostics/tests/inference/dependantOnVarianceNullable.fir.kt +++ /dev/null @@ -1,14 +0,0 @@ -package b -//+JDK - -import java.util.* -import java.util.Collections.* - -fun foo(list: List) : String { - val w : String = max(list, comparator {o1, o2 -> 1 - }) - return w -} - -//from library -fun comparator(fn: (T,T) -> Int): Comparator {} diff --git a/compiler/testData/diagnostics/tests/inference/dependantOnVarianceNullable.kt b/compiler/testData/diagnostics/tests/inference/dependantOnVarianceNullable.kt index d41dfec9cdb..f1a45b60267 100644 --- a/compiler/testData/diagnostics/tests/inference/dependantOnVarianceNullable.kt +++ b/compiler/testData/diagnostics/tests/inference/dependantOnVarianceNullable.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL package b //+JDK diff --git a/compiler/testData/diagnostics/tests/inference/mapFunction.fir.kt b/compiler/testData/diagnostics/tests/inference/mapFunction.fir.kt index df6c165eea9..2c65bab4694 100644 --- a/compiler/testData/diagnostics/tests/inference/mapFunction.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/mapFunction.fir.kt @@ -31,6 +31,6 @@ fun foo() { @Suppress("UNCHECKED_CAST") fun array(vararg t : T) : Array = t as Array -infix fun Array.map(transform : (T) -> R) : List {} +infix fun Array.map(transform : (T) -> R) : List {} -infix fun Iterable.map(transform : (T) -> R) : List {} +infix fun Iterable.map(transform : (T) -> R) : List {} diff --git a/compiler/testData/diagnostics/tests/inference/mostSpecificAfterInference.fir.kt b/compiler/testData/diagnostics/tests/inference/mostSpecificAfterInference.fir.kt index 04730ed66f5..af3c1ad5c1a 100644 --- a/compiler/testData/diagnostics/tests/inference/mostSpecificAfterInference.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/mostSpecificAfterInference.fir.kt @@ -6,8 +6,8 @@ package i import java.util.* import checkSubtype -fun Collection.map1(f : (T) -> R) : List {} -fun java.lang.Iterable.map1(f : (T) -> R) : List {} +fun Collection.map1(f : (T) -> R) : List {} +fun java.lang.Iterable.map1(f : (T) -> R) : List {} fun test(list: List) { val res = list.map1 { it } diff --git a/compiler/testData/diagnostics/tests/inference/possibleCycleOnConstraints.fir.kt b/compiler/testData/diagnostics/tests/inference/possibleCycleOnConstraints.fir.kt index 7769b0e9122..9157a35b3f9 100644 --- a/compiler/testData/diagnostics/tests/inference/possibleCycleOnConstraints.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/possibleCycleOnConstraints.fir.kt @@ -2,7 +2,7 @@ package a import java.util.* -fun g (f: () -> List) : T {} +fun g (f: () -> List) : T {} fun test() { //here possibly can be a cycle on constraints diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1029.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1029.fir.kt deleted file mode 100644 index c7fe8b75d3a..00000000000 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1029.fir.kt +++ /dev/null @@ -1,19 +0,0 @@ -// !CHECK_TYPE - -//KT-1029 Wrong type inference -package i - -import checkSubtype - -public fun from(yielder: ()->Iterable) : Iterable { -} - -public infix fun Iterable.where(predicate : (T)->Boolean) : ()->Iterable { -} - -fun a() { - val x = 0..200 - val odd = from (x where {it%2==0}) // I believe it should infer here - - checkSubtype>(odd) -} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1029.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1029.kt index d659c2191d8..57555c402e7 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1029.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1029.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !CHECK_TYPE //KT-1029 Wrong type inference diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1031.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1031.fir.kt deleted file mode 100644 index 69964f68375..00000000000 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1031.fir.kt +++ /dev/null @@ -1,22 +0,0 @@ -// !CHECK_TYPE - -//KT-1031 Can't infer type of `it` with two lambdas -package i - -import java.util.ArrayList -import checkSubtype - -public infix fun Iterable.where(predicate : (TItem)->Boolean) : ()->Iterable { -} - -public fun select(yielder: ()->Iterable, selector : (TItem)->TResult) : ()->Iterable { -} - -fun a() { - val x = 0..200 - val z = x where { i: Int -> i % 2 == 0 } - val yielder = select(x where { it%2==0 }, { it.toString() }) - - checkSubtype<() -> Iterable>(z) - checkSubtype<() -> Iterable>(yielder) -} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1031.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1031.kt index bb8ece02b4d..dfca7703e80 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1031.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1031.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !CHECK_TYPE //KT-1031 Can't infer type of `it` with two lambdas diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1127.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1127.fir.kt index 96b6369f20a..621b5d788ce 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1127.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1127.fir.kt @@ -2,7 +2,7 @@ package d -fun asList(t: T) : List? {} +fun asList(t: T) : List? {} fun main() { val list : List = asList("") diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1145.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1145.fir.kt index fde772c35a1..57c02275a3e 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1145.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1145.fir.kt @@ -12,6 +12,6 @@ fun test(numbers: Iterable) { } //from library -fun Iterable.map(transform : (T) -> R) : List {} +fun Iterable.map(transform : (T) -> R) : List {} -fun Iterable.fold(initial: T, operation: (T, T) -> T): T {} +fun Iterable.fold(initial: T, operation: (T, T) -> T): T {} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1410.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1410.fir.kt deleted file mode 100644 index 5a6978651e5..00000000000 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1410.fir.kt +++ /dev/null @@ -1,28 +0,0 @@ -// !CHECK_TYPE - -// KT-1410 Compiler does automatically infer type argument when using variance -//+JDK -package d - -import checkSubtype - -public fun MutableCollection.filterToMy(result : MutableList, filter : (T) -> Boolean) : MutableCollection { - for (t in this){ - if (filter(t)){ - result.add(t) - } - } - return this -} - -fun foo(result: MutableList, collection: MutableCollection, prefix : String){ - collection.filterToMy(result, {it.startsWith(prefix)}) -} - -fun test(result: MutableList, collection: MutableCollection, prefix : String){ - val c = collection.filterToMy(result, {it.startsWith(prefix)}) - checkSubtype>(c) -} - -//from library -fun String.startsWith(prefix: String) : Boolean {} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1410.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1410.kt index ace3591909b..c5525ab31ab 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1410.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1410.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !CHECK_TYPE // KT-1410 Compiler does automatically infer type argument when using variance diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1718.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1718.fir.kt index e88657b9d2e..d9d97a60beb 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1718.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1718.fir.kt @@ -14,5 +14,5 @@ fun test() { } //from library -fun arrayList(vararg values: T) : ArrayList {} -operator fun Iterable.plus(elements: Iterable): List {} +fun arrayList(vararg values: T) : ArrayList {} +operator fun Iterable.plus(elements: Iterable): List {} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2286.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2286.fir.kt index d705c1b79e8..ec488fbf8bb 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2286.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2286.fir.kt @@ -24,4 +24,4 @@ abstract class Buggy { } //from library -fun Iterable.find(predicate: (T) -> Boolean) : T? {} +fun Iterable.find(predicate: (T) -> Boolean) : T? {} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2407.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2407.fir.kt index 6d14b228639..bdd4d5e4708 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2407.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2407.fir.kt @@ -12,8 +12,8 @@ fun test() { } //from library -fun arrayList(vararg values: T) : ArrayList {} +fun arrayList(vararg values: T) : ArrayList {} -fun Collection.map(transform : (T) -> R) : List {} +fun Collection.map(transform : (T) -> R) : List {} -fun Iterable.fold(initial: T, operation: (T, T) -> T): T {} +fun Iterable.fold(initial: T, operation: (T, T) -> T): T {} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2459.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2459.fir.kt deleted file mode 100644 index 4e0e772278b..00000000000 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2459.fir.kt +++ /dev/null @@ -1,10 +0,0 @@ -//KT-2459 Type inference error -package b - -import java.util.* - -class B(val x: List) -fun f(x: T): B = B(arrayList(x)) - -// from standard library -fun arrayList(vararg values: T) : ArrayList {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2459.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2459.kt index 22ab737dd00..e823d8a7c41 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2459.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2459.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL //KT-2459 Type inference error package b diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2842.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2842.fir.kt deleted file mode 100644 index ff15f73a325..00000000000 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2842.fir.kt +++ /dev/null @@ -1,27 +0,0 @@ -package c - -interface A - -fun test(a: A?) { - a.foo() //no error -} - -fun A.foo() {} - -//------------ -fun test(nullabilityInfoMap: Map?) { - nullabilityInfoMap.iterator() //no error -} - -//resolves to -public fun Map.iterator(): Iterator> {} - - -//------------- -fun foo() : Boolean { - val nullableList = getNullableList() - return nullableList.contains("") - -} - -fun getNullableList(): List? = null \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2842.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2842.kt index cfaf66d57b6..ee67b451f86 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2842.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2842.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL package c interface A diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2883.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2883.fir.kt index 39828a9f952..c6a5bff3a78 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2883.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2883.fir.kt @@ -8,7 +8,7 @@ class Y(val itemToString: (TItem) -> String){ } fun bar(context : Y) : TItem{ -} +} fun foo(){ val stringToString : (String) -> String = { it } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt3007.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt3007.fir.kt deleted file mode 100644 index 495431f6f60..00000000000 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt3007.fir.kt +++ /dev/null @@ -1,43 +0,0 @@ -//KT-3007 Kotlin plugin 0.4.126 does not compile KAnnotator revision ba0a93eb -package a - -enum class SomeEnum { - FIRST, - SECOND -} - -// Doesn't work -fun Iterable.some() { - this.fold(SomeEnum.FIRST, {res : SomeEnum, value -> - if (res == SomeEnum.FIRST) SomeEnum.FIRST else SomeEnum.SECOND - }) -} - -fun tempFun() : SomeEnum { - return SomeEnum.FIRST -} - -// Doesn't work -fun Iterable.someSimpleWithFun() { - this.fold(SomeEnum.FIRST, {res : SomeEnum, value -> - tempFun() - }) -} - - -// Works -fun Iterable.someSimple() { - this.fold(SomeEnum.FIRST, {res : SomeEnum, value -> - SomeEnum.FIRST - }) -} - -// Works -fun Iterable.someInt() { - this.fold(0, {res : Int, value -> - if (res == 0) 1 else 0 - }) -} - -//from standard library -fun Iterable.fold(initial: R, operation: (R, T) -> R): R {} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt3007.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt3007.kt index a393e8cc33e..4b95658ea8c 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt3007.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt3007.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL //KT-3007 Kotlin plugin 0.4.126 does not compile KAnnotator revision ba0a93eb package a diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt3301.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt3301.fir.kt deleted file mode 100644 index 2f2ba646a29..00000000000 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt3301.fir.kt +++ /dev/null @@ -1,20 +0,0 @@ -//KT-3301 Inference with several supertypes fails - -package arrays - -interface A -interface B - -object CAB : A, B -object DAB : A, B - -fun m(args : Array) { - -} - -fun test122() { - m(array(CAB, DAB)) // Wrong error here: Array is inferred while expected Array is satisfied -} - -//from library -fun array(vararg t: T): Array {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt3301.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt3301.kt index 03559322857..159c5773734 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt3301.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt3301.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL //KT-3301 Inference with several supertypes fails package arrays diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt702.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt702.fir.kt index d5b256555be..e6b60586116 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt702.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt702.fir.kt @@ -2,7 +2,7 @@ package a //+JDK -fun getJavaClass() : java.lang.Class { } +fun getJavaClass() : java.lang.Class { } public class Throwables() { companion object { diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt943.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt943.fir.kt deleted file mode 100644 index de262a10f93..00000000000 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt943.fir.kt +++ /dev/null @@ -1,23 +0,0 @@ -// !CHECK_TYPE - -//KT-943 Type inference failed -package maze - -//+JDK -import java.util.Collections.* -import java.util.* -import checkSubtype - -fun foo(lines: List) { - val w = max(lines, comparator {o1, o2 -> - val l1 : Int = o1.length // Types of o1 and o2 are ERROR - val l2 = o2.length - l1 - l2 - }).sure() - checkSubtype(w) -} - -//standard library -fun T?.sure() : T = this!! - -public inline fun comparator(fn: (T,T) -> Int): Comparator {} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt943.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt943.kt index c1d5dfa1a36..4d6c326f3ff 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt943.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt943.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !CHECK_TYPE //KT-943 Type inference failed diff --git a/compiler/testData/diagnostics/tests/inference/reportingImprovements/subtypeForInvariantWithErrorGenerics.fir.kt b/compiler/testData/diagnostics/tests/inference/reportingImprovements/subtypeForInvariantWithErrorGenerics.fir.kt deleted file mode 100644 index c3d614ed0ca..00000000000 --- a/compiler/testData/diagnostics/tests/inference/reportingImprovements/subtypeForInvariantWithErrorGenerics.fir.kt +++ /dev/null @@ -1,12 +0,0 @@ -package a - -fun foo (f: ()->R, r: MutableList) = r.add(f()) -fun bar (r: MutableList, f: ()->R) = r.add(f()) - -fun test() { - val a = foo({1}, arrayListOf("")) //no type inference error on 'arrayListOf' - val b = bar(arrayListOf(""), {1}) -} - -// from standard library -fun arrayListOf(vararg values: T) : MutableList {} diff --git a/compiler/testData/diagnostics/tests/inference/reportingImprovements/subtypeForInvariantWithErrorGenerics.kt b/compiler/testData/diagnostics/tests/inference/reportingImprovements/subtypeForInvariantWithErrorGenerics.kt index 882e484a57e..54c6c58c841 100644 --- a/compiler/testData/diagnostics/tests/inference/reportingImprovements/subtypeForInvariantWithErrorGenerics.kt +++ b/compiler/testData/diagnostics/tests/inference/reportingImprovements/subtypeForInvariantWithErrorGenerics.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL package a fun foo (f: ()->R, r: MutableList) = r.add(f()) diff --git a/compiler/testData/diagnostics/tests/inference/upperBounds/useBoundsToInferTypeParamsSimple.fir.kt b/compiler/testData/diagnostics/tests/inference/upperBounds/useBoundsToInferTypeParamsSimple.fir.kt index 86b194be127..09559600ea0 100644 --- a/compiler/testData/diagnostics/tests/inference/upperBounds/useBoundsToInferTypeParamsSimple.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/upperBounds/useBoundsToInferTypeParamsSimple.fir.kt @@ -19,4 +19,4 @@ fun test(a: Any, s: MutableSet) { } //from standard library -fun arrayListOf(vararg t: T): MutableList {} +fun arrayListOf(vararg t: T): MutableList {} diff --git a/compiler/testData/diagnostics/tests/infos/SmartCasts.fir.kt b/compiler/testData/diagnostics/tests/infos/SmartCasts.fir.kt index 8f335bd058b..b32738470a8 100644 --- a/compiler/testData/diagnostics/tests/infos/SmartCasts.fir.kt +++ b/compiler/testData/diagnostics/tests/infos/SmartCasts.fir.kt @@ -150,7 +150,7 @@ fun illegalWhenBlock(a: Any): Int { is Int -> return a is String -> return a } -} +} fun declarations(a: Any?) { if (a is String) { val p4: String = a diff --git a/compiler/testData/diagnostics/tests/library/Collections.fir.kt b/compiler/testData/diagnostics/tests/library/Collections.fir.kt index 45371a280a8..21371848ae4 100644 --- a/compiler/testData/diagnostics/tests/library/Collections.fir.kt +++ b/compiler/testData/diagnostics/tests/library/Collections.fir.kt @@ -107,4 +107,4 @@ fun testMutableMap(m: MutableMap) { val mutableSet1: MutableSet> = m.entries } -fun array(vararg t: T): Array {} +fun array(vararg t: T): Array {} diff --git a/compiler/testData/diagnostics/tests/regressions/kt402.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt402.fir.kt deleted file mode 100644 index 85d7041cad0..00000000000 --- a/compiler/testData/diagnostics/tests/regressions/kt402.fir.kt +++ /dev/null @@ -1,8 +0,0 @@ -package kt402 - -fun getTypeChecker() : (Any)->Boolean { - { a : Any -> a is T } // reports unsupported -} -fun f() : (Any) -> Boolean { - return { a : Any -> a is String } -} diff --git a/compiler/testData/diagnostics/tests/regressions/kt402.kt b/compiler/testData/diagnostics/tests/regressions/kt402.kt index e70c0dc36b2..9d22ce87387 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt402.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt402.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL package kt402 fun getTypeChecker() : (Any)->Boolean { diff --git a/compiler/testData/diagnostics/tests/regressions/kt442.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt442.fir.kt deleted file mode 100644 index acdf2880dc0..00000000000 --- a/compiler/testData/diagnostics/tests/regressions/kt442.fir.kt +++ /dev/null @@ -1,31 +0,0 @@ -// KT-442 Type inference fails on with() - -fun funny(f : () -> T) : T = f() - -fun testFunny() { - val a : Int = funny {1} -} - -fun funny2(f : (t : T) -> T) : T {} - -fun testFunny2() { - val a : Int = funny2 {it} -} - -fun box() : String { - return generic_invoker { it } -} - -fun generic_invoker(gen : (String) -> T) : T { - return gen("") -} - -infix fun T.with(f : T.() -> Unit) { - f() -} - -fun main() { - val a = 1 with { - plus(1) - } -} diff --git a/compiler/testData/diagnostics/tests/regressions/kt442.kt b/compiler/testData/diagnostics/tests/regressions/kt442.kt index 1fbd6d186b5..c78a52981d2 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt442.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt442.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // KT-442 Type inference fails on with() fun funny(f : () -> T) : T = f() diff --git a/compiler/testData/diagnostics/tests/regressions/kt456.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt456.fir.kt deleted file mode 100644 index a26799fc949..00000000000 --- a/compiler/testData/diagnostics/tests/regressions/kt456.fir.kt +++ /dev/null @@ -1,30 +0,0 @@ -//KT-456 No check for obligatory return in getters - -package kt456 - -class A() { - val i: Int - get() : Int { //no error - } -} - -//more tests -class B() { - val i: Int - get() { //no error - } -} - -class C() { - val i : Int - get() : Int { - try { - doSmth() - } - finally { - doSmth() - } - } -} - -fun doSmth() {} diff --git a/compiler/testData/diagnostics/tests/regressions/kt456.kt b/compiler/testData/diagnostics/tests/regressions/kt456.kt index 65b7dabb402..e6c7aa3ec28 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt456.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt456.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL //KT-456 No check for obligatory return in getters package kt456 diff --git a/compiler/testData/diagnostics/tests/regressions/kt58.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt58.fir.kt index 6103492c7df..3747de7fe71 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt58.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt58.fir.kt @@ -85,7 +85,7 @@ fun t7() : Int { finally { doSmth(3) } -} +} fun doSmth(i: Int) { } diff --git a/compiler/testData/diagnostics/tests/smartCasts/kt3899.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/kt3899.fir.kt index 70b1312bca0..074180254cb 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/kt3899.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/kt3899.fir.kt @@ -3,7 +3,7 @@ data class StringPair(val first: String, val second: String) infix fun String.to(second: String) = StringPair(this, second) fun hashMapOf(pair: StringPair): MutableMap { -} +} fun F() : MutableMap { val value: String? = "xyz" diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/safeCallAndInPlaceReturn.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/safeCallAndInPlaceReturn.fir.kt index 4d895ffeb05..4c2f6ee2e99 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/safeCallAndInPlaceReturn.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/safeCallAndInPlaceReturn.fir.kt @@ -14,10 +14,10 @@ fun bad(): String { val x: String? = null x?.myRun { return "" } -} +} fun ok(): String { val x: String? = null x?.run { return "non-null" } ?: return "null" -} \ No newline at end of file +} diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/33.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/33.fir.kt index 76c42bfb6a0..a34ada3c25a 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/33.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/33.fir.kt @@ -85,6 +85,6 @@ fun case_6() { null!! } - x - x.minus(10.0) + x + x.minus(10.0) } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/36.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/36.fir.kt index a26ef8fcdc9..d4e64a42359 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/36.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/36.fir.kt @@ -78,7 +78,7 @@ fun case_5(x: Any?) { fun case_6(x: Any?) { var y = x ?: null!! while (false || y is Number) { - x + x y y.toByte() } @@ -91,7 +91,7 @@ fun case_6(x: Any?) { fun case_7(x: Any?, z: Any) { var y = x ?: null!! while (false || y === z) { - x + x y y.equals(10) } @@ -104,7 +104,7 @@ fun case_7(x: Any?, z: Any) { fun case_8(x: Any?, z: Any) { var y = x ?: null!! y == z || return - x + x y y.equals(10) } @@ -129,7 +129,7 @@ fun case_10(x: Any?, z: Any, b: Boolean?) { null -> throw Exception() } z === y || if (b == true) return else if (b === false) null!! else throw Exception() - x + x y y.equals(10) } diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt index cd4b8da308c..ca5f55ab27d 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt @@ -27,6 +27,7 @@ import org.jetbrains.kotlin.psi.KtCallExpression import org.jetbrains.kotlin.psi.KtClass import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtDeclaration +import org.jetbrains.kotlin.psi.KtDeclarationWithBody import org.jetbrains.kotlin.psi.KtDestructuringDeclaration import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtExpression @@ -2797,6 +2798,12 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert token, ) } + add(FirErrors.NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY) { firDiagnostic -> + NoReturnInFunctionWithBlockBodyImpl( + firDiagnostic as FirPsiDiagnostic, + token, + ) + } add(FirErrors.USAGE_IS_NOT_INLINABLE) { firDiagnostic -> UsageIsNotInlinableImpl( firSymbolBuilder.buildSymbol(firDiagnostic.a.fir), diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt index 8b1973adc84..3e2434cd563 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt @@ -34,6 +34,7 @@ import org.jetbrains.kotlin.psi.KtCallExpression import org.jetbrains.kotlin.psi.KtClass import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtDeclaration +import org.jetbrains.kotlin.psi.KtDeclarationWithBody import org.jetbrains.kotlin.psi.KtDestructuringDeclaration import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtExpression @@ -1964,6 +1965,10 @@ sealed class KtFirDiagnostic : KtDiagnosticWithPsi { override val diagnosticClass get() = ReturnInFunctionWithExpressionBody::class } + abstract class NoReturnInFunctionWithBlockBody : KtFirDiagnostic() { + override val diagnosticClass get() = NoReturnInFunctionWithBlockBody::class + } + abstract class UsageIsNotInlinable : KtFirDiagnostic() { override val diagnosticClass get() = UsageIsNotInlinable::class abstract val parameter: KtSymbol diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt index 44240569ff7..10d48f1252f 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt @@ -36,6 +36,7 @@ import org.jetbrains.kotlin.psi.KtCallExpression import org.jetbrains.kotlin.psi.KtClass import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtDeclaration +import org.jetbrains.kotlin.psi.KtDeclarationWithBody import org.jetbrains.kotlin.psi.KtDestructuringDeclaration import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtExpression @@ -3177,6 +3178,13 @@ internal class ReturnInFunctionWithExpressionBodyImpl( override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic) } +internal class NoReturnInFunctionWithBlockBodyImpl( + firDiagnostic: FirPsiDiagnostic, + override val token: ValidityToken, +) : KtFirDiagnostic.NoReturnInFunctionWithBlockBody(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic) +} + internal class UsageIsNotInlinableImpl( override val parameter: KtSymbol, firDiagnostic: FirPsiDiagnostic,