From d56412e39760a35ddf58fefdcf99d4e78abc5f7b Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 18 Nov 2019 14:23:23 +0300 Subject: [PATCH] [FIR] Analyze lambda arguments in erroneously resolved calls --- .../fir/resolve/inference/FirCallCompleter.kt | 10 +- .../arguments/incorrectFunctionalType.txt | 2 +- .../testData/resolve/arguments/lambda.txt | 16 +- .../arguments/lambdaInUnresolvedCall.kt | 14 + .../arguments/lambdaInUnresolvedCall.txt | 25 ++ .../resolve/testData/resolve/cfg/complex.dot | 398 +++++++++--------- .../resolve/testData/resolve/cfg/complex.txt | 2 +- .../genericSamInferenceFromExpectType.txt | 2 +- .../resolve/samConversions/genericSam.txt | 2 +- .../resolve/samConversions/kotlinSam.txt | 4 +- .../notSamBecauseOfSupertype.txt | 4 +- .../manyInnermanyOuterCandidatesAmbiguity.kt | 2 +- .../manyInnermanyOuterCandidatesAmbiguity.txt | 2 +- .../testData/resolve/stdlib/j+k/MyMap.txt | 4 +- .../fir/FirDiagnosticsTestGenerated.java | 5 + .../sam/samByProjectedType.fir.txt | 2 +- .../expressions/sam/samConstructors.fir.txt | 2 +- 17 files changed, 279 insertions(+), 217 deletions(-) create mode 100644 compiler/fir/resolve/testData/resolve/arguments/lambdaInUnresolvedCall.kt create mode 100644 compiler/fir/resolve/testData/resolve/arguments/lambdaInUnresolvedCall.txt diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt index 6ea3dba9673..db0fc0e7533 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt @@ -9,6 +9,7 @@ import org.jetbrains.kotlin.fir.copy import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirFunctionCall import org.jetbrains.kotlin.fir.expressions.FirResolvable import org.jetbrains.kotlin.fir.expressions.FirStatement import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents @@ -54,7 +55,14 @@ class FirCallCompleter( if (call is FirExpression) { call.resultType = typeRef } - return call + return if (call is FirFunctionCall) { + call.transformArguments( + transformer, + ResolutionMode.WithExpectedType(typeRef.resolvedTypeFromPrototype(session.builtinTypes.nullableAnyType.type)) + ) as T + } else { + call + } } val candidate = call.candidate() ?: return call val initialSubstitutor = candidate.substitutor diff --git a/compiler/fir/resolve/testData/resolve/arguments/incorrectFunctionalType.txt b/compiler/fir/resolve/testData/resolve/arguments/incorrectFunctionalType.txt index 91c07b808b9..58d453d4b58 100644 --- a/compiler/fir/resolve/testData/resolve/arguments/incorrectFunctionalType.txt +++ b/compiler/fir/resolve/testData/resolve/arguments/incorrectFunctionalType.txt @@ -3,7 +3,7 @@ FILE: incorrectFunctionalType.kt fun (): R|kotlin/Unit| { } public final fun test(): R|kotlin/Unit| { - #( = foo@fun .(): R|kotlin/String| { + #( = foo@fun (): R|kotlin/String| { this#.R|kotlin/plus|(#) } ) diff --git a/compiler/fir/resolve/testData/resolve/arguments/lambda.txt b/compiler/fir/resolve/testData/resolve/arguments/lambda.txt index 085792077c5..eb96253cdb9 100644 --- a/compiler/fir/resolve/testData/resolve/arguments/lambda.txt +++ b/compiler/fir/resolve/testData/resolve/arguments/lambda.txt @@ -18,14 +18,14 @@ FILE: lambda.kt Unit } ) - #(Int(1), = foo@fun .(): R|kotlin/Unit| { + #(Int(1), = foo@fun (): R|kotlin/Unit| { Unit } ) - #(f = foo@fun .(): R|kotlin/Unit| { + #(f = foo@fun (): R|kotlin/Unit| { Unit } - , = foo@fun .(): R|kotlin/Unit| { + , = foo@fun (): R|kotlin/Unit| { Unit } ) @@ -45,11 +45,11 @@ FILE: lambda.kt Unit } ) - #( = bar@fun .(): R|kotlin/Unit| { + #( = bar@fun (): R|kotlin/Unit| { Unit } ) - #(bar@fun .(): R|kotlin/Unit| { + #(bar@fun (): R|kotlin/Unit| { Unit } ) @@ -61,15 +61,15 @@ FILE: lambda.kt Unit } , Boolean(false)) - #( = baz@fun .(): R|kotlin/Unit| { + #( = baz@fun (): R|kotlin/Unit| { Unit } ) - #( = baz@fun .(): R|kotlin/Unit| { + #( = baz@fun (): R|kotlin/Unit| { Unit } ) - #(other = Boolean(false), = baz@fun .(): R|kotlin/Unit| { + #(other = Boolean(false), = baz@fun (): R|kotlin/Unit| { Unit } ) diff --git a/compiler/fir/resolve/testData/resolve/arguments/lambdaInUnresolvedCall.kt b/compiler/fir/resolve/testData/resolve/arguments/lambdaInUnresolvedCall.kt new file mode 100644 index 00000000000..449a5f75509 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/arguments/lambdaInUnresolvedCall.kt @@ -0,0 +1,14 @@ +fun materialize(): R = null!! + +fun test_1() { + myRun { + val x = 1 + x * 2 + } +} + +fun test_2() { + myRun { + materialize() + } +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/arguments/lambdaInUnresolvedCall.txt b/compiler/fir/resolve/testData/resolve/arguments/lambdaInUnresolvedCall.txt new file mode 100644 index 00000000000..b91a7dc1207 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/arguments/lambdaInUnresolvedCall.txt @@ -0,0 +1,25 @@ +FILE: lambdaInUnresolvedCall.kt + public final fun materialize(): R|R| { + ^materialize when (lval : R|kotlin/Nothing?| = Null(null)) { + ==($subj$, Null(null)) -> { + throw #() + } + else -> { + R|/| + } + } + + } + public final fun test_1(): R|kotlin/Unit| { + #( = myRun@fun (): R|kotlin/Int| { + lval x: R|kotlin/Int| = Int(1) + R|/x|.R|kotlin/Int.times|(Int(2)) + } + ) + } + public final fun test_2(): R|kotlin/Unit| { + #( = myRun@fun (): R|kotlin/Any?| { + R|/materialize|() + } + ) + } diff --git a/compiler/fir/resolve/testData/resolve/cfg/complex.dot b/compiler/fir/resolve/testData/resolve/cfg/complex.dot index 2860165170c..7712ded3178 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/complex.dot +++ b/compiler/fir/resolve/testData/resolve/cfg/complex.dot @@ -24,58 +24,62 @@ digraph complex_kt { 10 [label="Access variable #"]; 11 [label="Access variable R|/url|"]; 12 [label="Access variable R|/url|"]; - 13 [label="Function call: #.#(R|/url|)"]; - 14 [label="Function call: #.#(R|/url|).#( = connect@fun .(): { + 13 [label="Access variable R|/url|"]; + 14 [label="Function call: #.#(R|/url|)"]; + 15 [label="Function call: #.#(R|/url|).#( = connect@fun (): { #().#().#(#.#.#(), (#()).#) } )"]; - 15 [label="Exit block"]; + 16 [label="Exit block"]; } - 16 [label="Try main block exit"]; + 17 [label="Try main block exit"]; } subgraph cluster_4 { color=blue - 17 [label="Catch enter"]; + 18 [label="Catch enter"]; subgraph cluster_5 { color=blue - 18 [label="Enter block"]; - 19 [label="Const: String(Can't parse json response)"]; - 20 [label="Access variable R|/syntaxException|"]; - 21 [label="Const: String(Can't parse json response)"]; - 22 [label="Access variable R|/syntaxException|"]; - 23 [label="Function call: #(String(Can't parse json response), R|/syntaxException|)"]; - 24 [label="Throw: throw #(String(Can't parse json response), R|/syntaxException|)"]; - 25 [label="Stub" style="filled" fillcolor=gray]; - 26 [label="Exit block" style="filled" fillcolor=gray]; + 19 [label="Enter block"]; + 20 [label="Const: String(Can't parse json response)"]; + 21 [label="Access variable R|/syntaxException|"]; + 22 [label="Const: String(Can't parse json response)"]; + 23 [label="Access variable R|/syntaxException|"]; + 24 [label="Const: String(Can't parse json response)"]; + 25 [label="Access variable R|/syntaxException|"]; + 26 [label="Function call: #(String(Can't parse json response), R|/syntaxException|)"]; + 27 [label="Throw: throw #(String(Can't parse json response), R|/syntaxException|)"]; + 28 [label="Stub" style="filled" fillcolor=gray]; + 29 [label="Exit block" style="filled" fillcolor=gray]; } - 27 [label="Catch exit" style="filled" fillcolor=gray]; + 30 [label="Catch exit" style="filled" fillcolor=gray]; } subgraph cluster_6 { color=blue - 28 [label="Catch enter"]; + 31 [label="Catch enter"]; subgraph cluster_7 { color=blue - 29 [label="Enter block"]; - 30 [label="Access variable R|/ioException|"]; - 31 [label="Access variable R|/ioException|"]; - 32 [label="Function call: #(R|/ioException|)"]; - 33 [label="Throw: throw #(R|/ioException|)"]; - 34 [label="Stub" style="filled" fillcolor=gray]; - 35 [label="Exit block" style="filled" fillcolor=gray]; + 32 [label="Enter block"]; + 33 [label="Access variable R|/ioException|"]; + 34 [label="Access variable R|/ioException|"]; + 35 [label="Access variable R|/ioException|"]; + 36 [label="Function call: #(R|/ioException|)"]; + 37 [label="Throw: throw #(R|/ioException|)"]; + 38 [label="Stub" style="filled" fillcolor=gray]; + 39 [label="Exit block" style="filled" fillcolor=gray]; } - 36 [label="Catch exit" style="filled" fillcolor=gray]; + 40 [label="Catch exit" style="filled" fillcolor=gray]; } - 37 [label="Try expression exit"]; + 41 [label="Try expression exit"]; } - 38 [label="Variable declaration: lval pluginDTOs: R|kotlin/Array|"]; - 39 [label="Exit function fetchPluginReleaseDate" style="filled" fillcolor=red]; + 42 [label="Variable declaration: lval pluginDTOs: R|kotlin/Array|"]; + 43 [label="Exit function fetchPluginReleaseDate" style="filled" fillcolor=red]; } subgraph cluster_8 { color=blue - 40 [label="Enter annotation"]; - 41 [label="Access variable #"]; - 42 [label="Access variable #"]; - 43 [label="Exit annotation"]; + 44 [label="Enter annotation"]; + 45 [label="Access variable #"]; + 46 [label="Access variable #"]; + 47 [label="Exit annotation"]; } 0 -> {1}; @@ -86,7 +90,7 @@ digraph complex_kt { 5 -> {6}; 6 -> {7}; 7 -> {8}; - 8 -> {39 28 17 9}; + 8 -> {43 31 18 9}; 9 -> {10}; 10 -> {11}; 11 -> {12}; @@ -94,151 +98,157 @@ digraph complex_kt { 13 -> {14}; 14 -> {15}; 15 -> {16}; - 16 -> {37}; - 17 -> {39 18}; - 18 -> {19}; + 16 -> {17}; + 17 -> {41}; + 18 -> {43 19}; 19 -> {20}; 20 -> {21}; 21 -> {22}; 22 -> {23}; 23 -> {24}; - 24 -> {39}; - 24 -> {25} [style=dotted]; - 25 -> {26} [style=dotted]; - 26 -> {27} [style=dotted]; - 27 -> {37} [style=dotted]; - 28 -> {39 29}; - 29 -> {30}; - 30 -> {31}; - 31 -> {32}; + 24 -> {25}; + 25 -> {26}; + 26 -> {27}; + 27 -> {43}; + 27 -> {28} [style=dotted]; + 28 -> {29} [style=dotted]; + 29 -> {30} [style=dotted]; + 30 -> {41} [style=dotted]; + 31 -> {43 32}; 32 -> {33}; - 33 -> {39}; - 33 -> {34} [style=dotted]; - 34 -> {35} [style=dotted]; - 35 -> {36} [style=dotted]; - 36 -> {37} [style=dotted]; - 37 -> {38}; - 38 -> {39}; - 39 -> {40}; - 40 -> {41}; + 33 -> {34}; + 34 -> {35}; + 35 -> {36}; + 36 -> {37}; + 37 -> {43}; + 37 -> {38} [style=dotted]; + 38 -> {39} [style=dotted]; + 39 -> {40} [style=dotted]; + 40 -> {41} [style=dotted]; 41 -> {42}; 42 -> {43}; - - subgraph cluster_9 { - color=red - 44 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; - 45 [label="Function call: #()"]; - 46 [label="Function call: #().#()"]; - 47 [label="Access variable #"]; - 48 [label="Access variable #"]; - 49 [label="Function call: #.#.#()"]; - 50 [label="Function call: #()"]; - 51 [label="Access variable #"]; - 52 [label="Access variable #"]; - 53 [label="Function call: #().#().#(#.#.#(), (#()).#)"]; - 54 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; - } - + 43 -> {44}; 44 -> {45}; 45 -> {46}; 46 -> {47}; - 47 -> {48}; + + subgraph cluster_9 { + color=red + 48 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + 49 [label="Function call: #()"]; + 50 [label="Function call: #().#()"]; + 51 [label="Access variable #"]; + 52 [label="Access variable #"]; + 53 [label="Function call: #.#.#()"]; + 54 [label="Function call: #()"]; + 55 [label="Access variable #"]; + 56 [label="Access variable #"]; + 57 [label="Access variable #"]; + 58 [label="Function call: #().#().#(#.#.#(), (#()).#)"]; + 59 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + } + 48 -> {49}; 49 -> {50}; 50 -> {51}; 51 -> {52}; 52 -> {53}; 53 -> {54}; + 54 -> {55}; + 55 -> {56}; + 56 -> {57}; + 57 -> {58}; + 58 -> {59}; subgraph cluster_10 { color=red - 55 [label="Enter function close" style="filled" fillcolor=red]; - 56 [label="Exit function close" style="filled" fillcolor=red]; + 60 [label="Enter function close" style="filled" fillcolor=red]; + 61 [label="Exit function close" style="filled" fillcolor=red]; } - 55 -> {56}; + 60 -> {61}; subgraph cluster_11 { color=red - 57 [label="Enter function closeFinally" style="filled" fillcolor=red]; + 62 [label="Enter function closeFinally" style="filled" fillcolor=red]; subgraph cluster_12 { color=blue - 58 [label="Enter when"]; + 63 [label="Enter when"]; subgraph cluster_13 { - color=blue - 59 [label="Enter when branch condition "]; - 60 [label="Access variable this@R|/closeFinally|"]; - 61 [label="Const: Null(null)"]; - 62 [label="Operator =="]; - 63 [label="Exit when branch condition"]; - } - subgraph cluster_14 { color=blue 64 [label="Enter when branch condition "]; - 65 [label="Access variable R|/cause|"]; + 65 [label="Access variable this@R|/closeFinally|"]; 66 [label="Const: Null(null)"]; 67 [label="Operator =="]; 68 [label="Exit when branch condition"]; } + subgraph cluster_14 { + color=blue + 69 [label="Enter when branch condition "]; + 70 [label="Access variable R|/cause|"]; + 71 [label="Const: Null(null)"]; + 72 [label="Operator =="]; + 73 [label="Exit when branch condition"]; + } subgraph cluster_15 { color=blue - 69 [label="Enter when branch condition else"]; - 70 [label="Exit when branch condition"]; + 74 [label="Enter when branch condition else"]; + 75 [label="Exit when branch condition"]; } - 71 [label="Enter when branch result"]; + 76 [label="Enter when branch result"]; subgraph cluster_16 { color=blue - 72 [label="Enter block"]; + 77 [label="Enter block"]; subgraph cluster_17 { color=blue - 73 [label="Try expression enter"]; + 78 [label="Try expression enter"]; subgraph cluster_18 { color=blue - 74 [label="Try main block enter"]; + 79 [label="Try main block enter"]; subgraph cluster_19 { color=blue - 75 [label="Enter block"]; - 76 [label="Function call: this@R|/AutoCloseable|.R|/AutoCloseable.close|()"]; - 77 [label="Exit block"]; + 80 [label="Enter block"]; + 81 [label="Function call: this@R|/AutoCloseable|.R|/AutoCloseable.close|()"]; + 82 [label="Exit block"]; } - 78 [label="Try main block exit"]; + 83 [label="Try main block exit"]; } subgraph cluster_20 { color=blue - 79 [label="Catch enter"]; + 84 [label="Catch enter"]; subgraph cluster_21 { color=blue - 80 [label="Enter block"]; - 81 [label="Access variable R|/cause|"]; - 82 [label="Access variable R|/closeException|"]; - 83 [label="Function call: R|/cause|.R|kotlin/addSuppressed|(R|/closeException|)"]; - 84 [label="Exit block"]; + 85 [label="Enter block"]; + 86 [label="Access variable R|/cause|"]; + 87 [label="Access variable R|/closeException|"]; + 88 [label="Function call: R|/cause|.R|kotlin/addSuppressed|(R|/closeException|)"]; + 89 [label="Exit block"]; } - 85 [label="Catch exit"]; + 90 [label="Catch exit"]; } - 86 [label="Try expression exit"]; + 91 [label="Try expression exit"]; } - 87 [label="Exit block"]; - } - 88 [label="Exit when branch result"]; - 89 [label="Enter when branch result"]; - subgraph cluster_22 { - color=blue - 90 [label="Enter block"]; - 91 [label="Function call: this@R|/AutoCloseable|.R|/AutoCloseable.close|()"]; 92 [label="Exit block"]; } 93 [label="Exit when branch result"]; 94 [label="Enter when branch result"]; - subgraph cluster_23 { + subgraph cluster_22 { color=blue 95 [label="Enter block"]; - 96 [label="Exit block"]; + 96 [label="Function call: this@R|/AutoCloseable|.R|/AutoCloseable.close|()"]; + 97 [label="Exit block"]; } - 97 [label="Exit when branch result"]; - 98 [label="Exit when"]; + 98 [label="Exit when branch result"]; + 99 [label="Enter when branch result"]; + subgraph cluster_23 { + color=blue + 100 [label="Enter block"]; + 101 [label="Exit block"]; + } + 102 [label="Exit when branch result"]; + 103 [label="Exit when"]; } - 99 [label="Jump: ^closeFinally when () { + 104 [label="Jump: ^closeFinally when () { ==(this@R|/closeFinally|, Null(null)) -> { } ==(R|/cause|, Null(null)) -> { @@ -255,155 +265,155 @@ digraph complex_kt { } } "]; - 100 [label="Stub" style="filled" fillcolor=gray]; - 101 [label="Exit function closeFinally" style="filled" fillcolor=red]; + 105 [label="Stub" style="filled" fillcolor=gray]; + 106 [label="Exit function closeFinally" style="filled" fillcolor=red]; } - 57 -> {58}; - 58 -> {59}; - 59 -> {60}; - 60 -> {61}; - 61 -> {62}; 62 -> {63}; - 63 -> {94 64}; + 63 -> {64}; 64 -> {65}; 65 -> {66}; 66 -> {67}; 67 -> {68}; - 68 -> {89 69}; + 68 -> {99 69}; 69 -> {70}; 70 -> {71}; 71 -> {72}; 72 -> {73}; - 73 -> {74}; - 74 -> {101 79 75}; + 73 -> {94 74}; + 74 -> {75}; 75 -> {76}; 76 -> {77}; 77 -> {78}; - 78 -> {86}; - 79 -> {101 80}; + 78 -> {79}; + 79 -> {106 84 80}; 80 -> {81}; 81 -> {82}; 82 -> {83}; - 83 -> {84}; - 84 -> {85}; + 83 -> {91}; + 84 -> {106 85}; 85 -> {86}; 86 -> {87}; 87 -> {88}; - 88 -> {98}; + 88 -> {89}; 89 -> {90}; 90 -> {91}; 91 -> {92}; 92 -> {93}; - 93 -> {98}; + 93 -> {103}; 94 -> {95}; 95 -> {96}; 96 -> {97}; 97 -> {98}; - 98 -> {99}; - 99 -> {101}; - 99 -> {100} [style=dotted]; - 100 -> {101} [style=dotted]; + 98 -> {103}; + 99 -> {100}; + 100 -> {101}; + 101 -> {102}; + 102 -> {103}; + 103 -> {104}; + 104 -> {106}; + 104 -> {105} [style=dotted]; + 105 -> {106} [style=dotted]; subgraph cluster_24 { color=red - 102 [label="Enter function firstIsInstanceOrNull" style="filled" fillcolor=red]; - 103 [label="Access variable this@R|/firstIsInstanceOrNull|"]; - 104 [label="Variable declaration: lval : R|kotlin/sequences/Sequence<*>|"]; - 105 [label="Access variable R|/|"]; - 106 [label="Function call: R|/|.R|kotlin/sequences/Sequence.iterator|()"]; - 107 [label="Variable declaration: lval : R|kotlin/collections/Iterator|"]; + 107 [label="Enter function firstIsInstanceOrNull" style="filled" fillcolor=red]; + 108 [label="Access variable this@R|/firstIsInstanceOrNull|"]; + 109 [label="Variable declaration: lval : R|kotlin/sequences/Sequence<*>|"]; + 110 [label="Access variable R|/|"]; + 111 [label="Function call: R|/|.R|kotlin/sequences/Sequence.iterator|()"]; + 112 [label="Variable declaration: lval : R|kotlin/collections/Iterator|"]; subgraph cluster_25 { color=blue - 108 [label="Enter while loop"]; + 113 [label="Enter while loop"]; subgraph cluster_26 { color=blue - 109 [label="Enter loop condition"]; - 110 [label="Access variable R|/|"]; - 111 [label="Function call: R|/|.R|kotlin/collections/Iterator.hasNext|()"]; - 112 [label="Exit loop condition"]; + 114 [label="Enter loop condition"]; + 115 [label="Access variable R|/|"]; + 116 [label="Function call: R|/|.R|kotlin/collections/Iterator.hasNext|()"]; + 117 [label="Exit loop condition"]; } subgraph cluster_27 { color=blue - 113 [label="Enter loop block"]; + 118 [label="Enter loop block"]; subgraph cluster_28 { color=blue - 114 [label="Enter block"]; - 115 [label="Access variable R|/|"]; - 116 [label="Function call: R|/|.R|FakeOverride|()"]; - 117 [label="Variable declaration: lval element: R|T|"]; + 119 [label="Enter block"]; + 120 [label="Access variable R|/|"]; + 121 [label="Function call: R|/|.R|FakeOverride|()"]; + 122 [label="Variable declaration: lval element: R|T|"]; subgraph cluster_29 { color=blue - 118 [label="Enter when"]; + 123 [label="Enter when"]; subgraph cluster_30 { color=blue - 119 [label="Enter when branch condition "]; - 120 [label="Access variable R|/element|"]; - 121 [label="Type operator: element is T"]; - 122 [label="Exit when branch condition"]; + 124 [label="Enter when branch condition "]; + 125 [label="Access variable R|/element|"]; + 126 [label="Type operator: element is T"]; + 127 [label="Exit when branch condition"]; } - 123 [label="Synthetic else branch"]; - 124 [label="Enter when branch result"]; + 128 [label="Synthetic else branch"]; + 129 [label="Enter when branch result"]; subgraph cluster_31 { color=blue - 125 [label="Enter block"]; - 126 [label="Access variable R|/element|"]; - 127 [label="Jump: ^firstIsInstanceOrNull R|/element|"]; - 128 [label="Stub" style="filled" fillcolor=gray]; - 129 [label="Exit block" style="filled" fillcolor=gray]; + 130 [label="Enter block"]; + 131 [label="Access variable R|/element|"]; + 132 [label="Jump: ^firstIsInstanceOrNull R|/element|"]; + 133 [label="Stub" style="filled" fillcolor=gray]; + 134 [label="Exit block" style="filled" fillcolor=gray]; } - 130 [label="Exit when branch result" style="filled" fillcolor=gray]; - 131 [label="Exit when"]; + 135 [label="Exit when branch result" style="filled" fillcolor=gray]; + 136 [label="Exit when"]; } - 132 [label="Exit block"]; + 137 [label="Exit block"]; } - 133 [label="Exit loop block"]; + 138 [label="Exit loop block"]; } - 134 [label="Exit whileloop"]; + 139 [label="Exit whileloop"]; } - 135 [label="Const: Null(null)"]; - 136 [label="Jump: ^firstIsInstanceOrNull Null(null)"]; - 137 [label="Stub" style="filled" fillcolor=gray]; - 138 [label="Exit function firstIsInstanceOrNull" style="filled" fillcolor=red]; + 140 [label="Const: Null(null)"]; + 141 [label="Jump: ^firstIsInstanceOrNull Null(null)"]; + 142 [label="Stub" style="filled" fillcolor=gray]; + 143 [label="Exit function firstIsInstanceOrNull" style="filled" fillcolor=red]; } - 102 -> {103}; - 103 -> {104}; - 104 -> {105}; - 105 -> {106}; - 106 -> {107}; 107 -> {108}; 108 -> {109}; 109 -> {110}; 110 -> {111}; 111 -> {112}; - 112 -> {134 113}; + 112 -> {113}; 113 -> {114}; 114 -> {115}; 115 -> {116}; 116 -> {117}; - 117 -> {118}; + 117 -> {139 118}; 118 -> {119}; 119 -> {120}; 120 -> {121}; 121 -> {122}; - 122 -> {124 123}; - 123 -> {131}; + 122 -> {123}; + 123 -> {124}; 124 -> {125}; 125 -> {126}; 126 -> {127}; - 127 -> {138}; - 127 -> {128} [style=dotted]; - 128 -> {129} [style=dotted]; - 129 -> {130} [style=dotted]; - 130 -> {131} [style=dotted]; + 127 -> {129 128}; + 128 -> {136}; + 129 -> {130}; + 130 -> {131}; 131 -> {132}; - 132 -> {133}; - 133 -> {109}; - 134 -> {135}; - 135 -> {136}; - 136 -> {138}; - 136 -> {137} [style=dotted]; - 137 -> {138} [style=dotted]; + 132 -> {143}; + 132 -> {133} [style=dotted]; + 133 -> {134} [style=dotted]; + 134 -> {135} [style=dotted]; + 135 -> {136} [style=dotted]; + 136 -> {137}; + 137 -> {138}; + 138 -> {114}; + 139 -> {140}; + 140 -> {141}; + 141 -> {143}; + 141 -> {142} [style=dotted]; + 142 -> {143} [style=dotted]; } diff --git a/compiler/fir/resolve/testData/resolve/cfg/complex.txt b/compiler/fir/resolve/testData/resolve/cfg/complex.txt index 101bf4bfeb6..5259aef435a 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/complex.txt +++ b/compiler/fir/resolve/testData/resolve/cfg/complex.txt @@ -2,7 +2,7 @@ FILE: complex.kt @R|kotlin/jvm/Throws|((#), (#)) public final fun fetchPluginReleaseDate(pluginId: R|class error: Symbol not found, for `PluginId`|, version: R|kotlin/String|, channel: R|kotlin/String?|): R|class error: Symbol not found, for `LocalDate?`| { lval url: R|kotlin/String| = (String(https://plugins.jetbrains.com/api/plugins/), R|/pluginId|.#, String(/updates?version=), R|/version|) lval pluginDTOs: R|kotlin/Array| = try { - #.#(R|/url|).#( = connect@fun .(): { + #.#(R|/url|).#( = connect@fun (): { #().#().#(#.#.#(), (#()).#) } ) diff --git a/compiler/fir/resolve/testData/resolve/samConstructors/genericSamInferenceFromExpectType.txt b/compiler/fir/resolve/testData/resolve/samConstructors/genericSamInferenceFromExpectType.txt index 14283069be5..8e93c6ca63c 100644 --- a/compiler/fir/resolve/testData/resolve/samConstructors/genericSamInferenceFromExpectType.txt +++ b/compiler/fir/resolve/testData/resolve/samConstructors/genericSamInferenceFromExpectType.txt @@ -14,7 +14,7 @@ FILE: main.kt R|/x|.R|kotlin/Number.toInt|().R|kotlin/Any.toString|() } )) - #(R?C|/MyFunction|( = MyFunction@fun (x: R|kotlin/Int|): R|kotlin/String| { + #(R|/MyFunction||>( = MyFunction@fun (x: R|kotlin/Int|): R|kotlin/String| { R|/x|.R|kotlin/Any.toString|() } )) diff --git a/compiler/fir/resolve/testData/resolve/samConversions/genericSam.txt b/compiler/fir/resolve/testData/resolve/samConversions/genericSam.txt index 1906e6b483d..33a4997fdbd 100644 --- a/compiler/fir/resolve/testData/resolve/samConversions/genericSam.txt +++ b/compiler/fir/resolve/testData/resolve/samConversions/genericSam.txt @@ -8,7 +8,7 @@ FILE: main.kt R|/x|.R|kotlin/Number.toInt|().R|kotlin/Any.toString|() } ) - Q|JavaUsage|.#( = foo2@fun .(x: R|kotlin/Int|): R|kotlin/String| { + Q|JavaUsage|.#( = foo2@fun (x: R|kotlin/Int|): R|kotlin/String| { R|/x|.R|kotlin/Any.toString|() } ) diff --git a/compiler/fir/resolve/testData/resolve/samConversions/kotlinSam.txt b/compiler/fir/resolve/testData/resolve/samConversions/kotlinSam.txt index 6ce510fe066..74bb3553f51 100644 --- a/compiler/fir/resolve/testData/resolve/samConversions/kotlinSam.txt +++ b/compiler/fir/resolve/testData/resolve/samConversions/kotlinSam.txt @@ -38,12 +38,12 @@ FILE: kotlinSam.kt } ) R|/foo1|(R|/f|) - #( = foo2@fun .(x: ): R|kotlin/Boolean| { + #( = foo2@fun (x: R|class error: No type for parameter|): R|kotlin/Boolean| { >(R|/x|, Int(1)) } ) #(R|/f|) - #( = foo3@fun .(x: ): R|kotlin/Boolean| { + #( = foo3@fun (x: R|class error: No type for parameter|): R|kotlin/Boolean| { >(R|/x|, Int(1)) } ) diff --git a/compiler/fir/resolve/testData/resolve/samConversions/notSamBecauseOfSupertype.txt b/compiler/fir/resolve/testData/resolve/samConversions/notSamBecauseOfSupertype.txt index cedcacf33fb..b2508c111a3 100644 --- a/compiler/fir/resolve/testData/resolve/samConversions/notSamBecauseOfSupertype.txt +++ b/compiler/fir/resolve/testData/resolve/samConversions/notSamBecauseOfSupertype.txt @@ -2,11 +2,11 @@ FILE: main.kt public final fun foo(m: R|MyRunnable|): R|kotlin/Unit| { } public final fun main(): R|kotlin/Unit| { - Q|JavaUsage|.#( = foo@fun .(x: ): R|kotlin/Boolean| { + Q|JavaUsage|.#( = foo@fun (x: R|class error: No type for parameter|): R|kotlin/Boolean| { >(R|/x|, Int(1)) } ) - Q|JavaUsage|.#(foo@fun .(): R|kotlin/Boolean| { + Q|JavaUsage|.#(foo@fun (): R|kotlin/Boolean| { >(#, Int(1)) } ) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.kt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.kt index 0f6d0113065..10944f406ca 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.kt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.kt @@ -6,5 +6,5 @@ fun bar(): Int = 1 fun bar(x: String): Int = 1 fun main() { - foo(::bar) + foo(::bar) } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.txt index 38a5da03347..a5f610ab48b 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.txt @@ -10,5 +10,5 @@ FILE: manyInnermanyOuterCandidatesAmbiguity.kt ^bar Int(1) } public final fun main(): R|kotlin/Unit| { - #(::bar#) + #(::#) } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyMap.txt b/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyMap.txt index 9d76304d675..c27ac926ce2 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyMap.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyMap.txt @@ -6,7 +6,7 @@ FILE: test.kt ) lval otherResult: R|kotlin/String| = R|/map|.R|FakeOverride|(String(key), String(value)) lval anotherResult: = R|/map|.#(String(key), String(value)) - R|/map|.#( = forEach@fun .(key: , value: ): R|kotlin/Unit| { + R|/map|.#( = forEach@fun (key: R|class error: No type for parameter|, value: R|class error: No type for parameter|): R|kotlin/Unit| { R|kotlin/io/println|((R|/key|, String(: ), R|/value|)) } ) @@ -24,7 +24,7 @@ FILE: test.kt ) lval otherResult: R|kotlin/String| = R|/map|.R|FakeOverride|(String(key), String(value)) lval anotherResult: = R|/map|.#(String(key), String(value)) - R|/map|.#( = forEach@fun .(key: , value: ): R|kotlin/Unit| { + R|/map|.#( = forEach@fun (key: R|class error: No type for parameter|, value: R|class error: No type for parameter|): R|kotlin/Unit| { R|kotlin/io/println|((R|/key|, String(: ), R|/value|)) } ) diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java index ade0fd9cd12..fafec4b52bf 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -270,6 +270,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { runTest("compiler/fir/resolve/testData/resolve/arguments/lambdaInLambda2.kt"); } + @TestMetadata("lambdaInUnresolvedCall.kt") + public void testLambdaInUnresolvedCall() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/arguments/lambdaInUnresolvedCall.kt"); + } + @TestMetadata("overloadByReceiver.kt") public void testOverloadByReceiver() throws Exception { runTest("compiler/fir/resolve/testData/resolve/arguments/overloadByReceiver.kt"); diff --git a/compiler/testData/ir/irText/expressions/sam/samByProjectedType.fir.txt b/compiler/testData/ir/irText/expressions/sam/samByProjectedType.fir.txt index d63dbcde3a5..244c77590ef 100644 --- a/compiler/testData/ir/irText/expressions/sam/samByProjectedType.fir.txt +++ b/compiler/testData/ir/irText/expressions/sam/samByProjectedType.fir.txt @@ -2,7 +2,7 @@ FILE fqName: fileName:/samByProjectedType.kt FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUN_EXPR type=IrErrorType origin=LAMBDA + FUN_EXPR type=kotlin.Function1 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Any VALUE_PARAMETER name:x index:0 type:kotlin.Any BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.txt b/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.txt index f457d98a1bb..47ad7028b2a 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.txt @@ -24,7 +24,7 @@ FILE fqName: fileName:/samConstructors.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test4 (): IrErrorType declared in ' ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUN_EXPR type=IrErrorType origin=LAMBDA + FUN_EXPR type=kotlin.Function2 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (a:IrErrorType, b:IrErrorType) returnType:IrErrorType VALUE_PARAMETER name:a index:0 type:IrErrorType VALUE_PARAMETER name:b index:1 type:IrErrorType