From 820da6edaa3cf49b28c453a91c43b1f789b913db Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 13 Mar 2020 13:09:33 +0300 Subject: [PATCH] [FIR] Don't set up expected type for function body --- .../FirDeclarationsResolveTransformer.kt | 18 +- .../arguments/operatorsOverLiterals.txt | 2 +- .../invoke/threeReceiversCorrect.txt | 4 +- ...lexLambdaWithTypeVariableAsExpectedType.kt | 6 + ...exLambdaWithTypeVariableAsExpectedType.txt | 16 ++ .../receivers/implicitReceivers.dot | 268 +++++++++--------- .../receivers/implicitReceivers.txt | 2 +- ...leReferenceDependingOnInferredReceiver.txt | 6 +- .../eagerAndPostponedCallableReferences.txt | 2 +- .../fir/FirDiagnosticsTestGenerated.java | 5 + ...DiagnosticsWithLightTreeTestGenerated.java | 5 + .../generic/nestedCallWithOverload.fir.fail | 8 - .../generic/nestedCallWithOverload.fir.kt | 2 +- .../tests/inference/kt36044.fir.fail | 8 - .../tests/inference/kt36044.fir.kt | 9 - .../diagnostics/tests/inference/kt36044.kt | 1 + .../lambdaNothingAndExpectedType.fir.kt | 2 +- .../ir/irText/expressions/ifElseIf.fir.txt | 6 +- .../ir/irText/lambdas/nonLocalReturn.fir.txt | 15 +- 19 files changed, 199 insertions(+), 186 deletions(-) create mode 100644 compiler/fir/resolve/testData/resolve/problems/complexLambdaWithTypeVariableAsExpectedType.kt create mode 100644 compiler/fir/resolve/testData/resolve/problems/complexLambdaWithTypeVariableAsExpectedType.txt delete mode 100644 compiler/testData/diagnostics/tests/callableReference/generic/nestedCallWithOverload.fir.fail delete mode 100644 compiler/testData/diagnostics/tests/inference/kt36044.fir.fail delete mode 100644 compiler/testData/diagnostics/tests/inference/kt36044.fir.kt diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt index 914aea5c216..eecc6ce3d5f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt @@ -238,13 +238,19 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer) } else { returnTypeRef } + val resolutionMode = if (expectedReturnTypeRef.coneTypeSafe() == session.builtinTypes.unitType.type) { + ResolutionMode.ContextIndependent + } else { + withExpectedType(expectedReturnTypeRef) + } + val receiverTypeRef = owner.receiverTypeRef if (receiverTypeRef != null) { withLabelAndReceiverType(owner.name, owner, receiverTypeRef.coneTypeUnsafe()) { - transformFunctionWithGivenSignature(accessor, expectedReturnTypeRef) + transformFunctionWithGivenSignature(accessor, resolutionMode) } } else { - transformFunctionWithGivenSignature(accessor, expectedReturnTypeRef) + transformFunctionWithGivenSignature(accessor, resolutionMode) } } @@ -392,10 +398,10 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer) val receiverTypeRef = simpleFunction.receiverTypeRef if (receiverTypeRef != null) { withLabelAndReceiverType(simpleFunction.name, simpleFunction, receiverTypeRef.coneTypeUnsafe()) { - transformFunctionWithGivenSignature(simpleFunction, returnTypeRef) + transformFunctionWithGivenSignature(simpleFunction, ResolutionMode.ContextIndependent) } } else { - transformFunctionWithGivenSignature(simpleFunction, returnTypeRef) + transformFunctionWithGivenSignature(simpleFunction, ResolutionMode.ContextIndependent) } } } @@ -403,14 +409,14 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer) private fun > transformFunctionWithGivenSignature( function: F, - returnTypeRef: FirTypeRef, + resolutionMode: ResolutionMode, ): CompositeTransformResult { if (function is FirSimpleFunction) { components.storeFunction(function) } @Suppress("UNCHECKED_CAST") - val result = transformFunction(function, withExpectedType(returnTypeRef)).single as F + val result = transformFunction(function, resolutionMode).single as F val body = result.body if (result.returnTypeRef is FirImplicitTypeRef) { diff --git a/compiler/fir/resolve/testData/resolve/arguments/operatorsOverLiterals.txt b/compiler/fir/resolve/testData/resolve/arguments/operatorsOverLiterals.txt index ea1bfcf2dee..7df6da04e07 100644 --- a/compiler/fir/resolve/testData/resolve/arguments/operatorsOverLiterals.txt +++ b/compiler/fir/resolve/testData/resolve/arguments/operatorsOverLiterals.txt @@ -68,7 +68,7 @@ FILE: operatorsOverLiterals.kt ^ Int(1) } ) - Int(1).R|/plus|(R|kotlin/run|( = run@fun (): R|kotlin/Int| { + Int(1).R|kotlin/Int.plus|(R|kotlin/run|( = run@fun (): R|kotlin/Int| { ^ Int(1) } )) diff --git a/compiler/fir/resolve/testData/resolve/expresssions/invoke/threeReceiversCorrect.txt b/compiler/fir/resolve/testData/resolve/expresssions/invoke/threeReceiversCorrect.txt index cbfe92b1d67..93bf34fe658 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/invoke/threeReceiversCorrect.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/invoke/threeReceiversCorrect.txt @@ -31,9 +31,9 @@ FILE: threeReceiversCorrect.kt (this@R|special/anonymous|, R|/b|).R|/A.foo|.R|FakeOverride|(R|/c|) } ) - R|/with|(R|/b|, = with@fun R|B|.(): R|kotlin/Unit| { + ^ R|/with|(R|/b|, = with@fun R|B|.(): R|kotlin/Unit| { this@R|special/anonymous|.R|/A.foo|.R|FakeOverride|(R|/c|) - R|/with|(R|/c|, = with@fun R|C|.(): R|kotlin/Unit| { + ^ R|/with|(R|/c|, = with@fun R|C|.(): R|kotlin/Unit| { (this@R|special/anonymous|, this@R|special/anonymous|).R|/A.foo|.R|FakeOverride|(this@R|special/anonymous|) } ) diff --git a/compiler/fir/resolve/testData/resolve/problems/complexLambdaWithTypeVariableAsExpectedType.kt b/compiler/fir/resolve/testData/resolve/problems/complexLambdaWithTypeVariableAsExpectedType.kt new file mode 100644 index 00000000000..cc1de920011 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/problems/complexLambdaWithTypeVariableAsExpectedType.kt @@ -0,0 +1,6 @@ +fun id(x: T): T = x +fun select(x: K, y: K): K = TODO() + +fun test() { + select(id { it.inv() }, id<(Int) -> Unit> { }) +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/problems/complexLambdaWithTypeVariableAsExpectedType.txt b/compiler/fir/resolve/testData/resolve/problems/complexLambdaWithTypeVariableAsExpectedType.txt new file mode 100644 index 00000000000..8620b23cc0f --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/problems/complexLambdaWithTypeVariableAsExpectedType.txt @@ -0,0 +1,16 @@ +FILE: complexLambdaWithTypeVariableAsExpectedType.kt + public final fun id(x: R|T|): R|T| { + ^id R|/x| + } + public final fun select(x: R|K|, y: R|K|): R|K| { + ^select R|kotlin/TODO|() + } + public final fun test(): R|kotlin/Unit| { + R|/select| kotlin/Unit|>(R|/id| kotlin/Int|>( = id@fun (it: R|kotlin/Int|): R|kotlin/Int| { + ^ R|/it|.R|kotlin/Int.inv|() + } + ), R|/id| kotlin/Unit|>( = id@fun (it: R|kotlin/Int|): R|kotlin/Unit| { + Unit + } + )) + } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceivers.dot b/compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceivers.dot index 68331e84712..f8d09dba4b0 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceivers.dot +++ b/compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceivers.dot @@ -226,25 +226,24 @@ digraph implicitReceivers_kt { 87 [label="Function call: this@R|special/anonymous|.R|/A.foo|()"]; 88 [label="Exit function anonymousFunction"]; } - 89 [label="Call arguments union" style="filled" fillcolor=yellow]; - 90 [label="Postponed exit from lambda"]; - 91 [label="Function call: R|kotlin/with|(...)"]; - 92 [label="Exit function anonymousFunction"]; + 89 [label="Postponed exit from lambda"]; + 90 [label="Function call: R|kotlin/with|(...)"]; + 91 [label="Exit function anonymousFunction"]; } - 93 [label="Call arguments union" style="filled" fillcolor=yellow]; - 94 [label="Postponed exit from lambda"]; - 95 [label="Function call: R|kotlin/with|(...)"]; - 96 [label="Exit function test_3" style="filled" fillcolor=red]; + 92 [label="Call arguments union" style="filled" fillcolor=yellow]; + 93 [label="Postponed exit from lambda"]; + 94 [label="Function call: R|kotlin/with|(...)"]; + 95 [label="Exit function test_3" style="filled" fillcolor=red]; } 66 -> {67}; 67 -> {68}; 68 -> {69}; - 68 -> {94} [color=red]; + 68 -> {93} [color=red]; 69 -> {70}; 70 -> {71}; 71 -> {72}; - 71 -> {90} [color=red]; + 71 -> {89} [color=red]; 72 -> {73}; 73 -> {74}; 74 -> {75}; @@ -263,115 +262,115 @@ digraph implicitReceivers_kt { 85 -> {86}; 86 -> {87}; 87 -> {88}; - 88 -> {90} [color=green]; - 88 -> {89} [color=red]; - 89 -> {91} [color=red]; - 90 -> {91} [color=green]; - 91 -> {92}; - 92 -> {94} [color=green]; - 92 -> {93} [color=red]; - 93 -> {95} [color=red]; - 94 -> {95} [color=green]; - 95 -> {96}; + 88 -> {89} [color=green]; + 88 -> {92} [color=red]; + 89 -> {90}; + 90 -> {91}; + 91 -> {93} [color=green]; + 91 -> {92} [color=red]; + 92 -> {94} [color=red]; + 93 -> {94} [color=green]; + 94 -> {95}; subgraph cluster_21 { color=red - 97 [label="Enter function test_4" style="filled" fillcolor=red]; + 96 [label="Enter function test_4" style="filled" fillcolor=red]; subgraph cluster_22 { color=blue - 98 [label="Enter when"]; + 97 [label="Enter when"]; subgraph cluster_23 { color=blue - 99 [label="Enter when branch condition "]; - 100 [label="Access variable this@R|/test_4|"]; - 101 [label="Type operator: (this@R|/test_4| !is R|A|)"]; - 102 [label="Exit when branch condition"]; + 98 [label="Enter when branch condition "]; + 99 [label="Access variable this@R|/test_4|"]; + 100 [label="Type operator: (this@R|/test_4| !is R|A|)"]; + 101 [label="Exit when branch condition"]; } subgraph cluster_24 { color=blue - 103 [label="Enter when branch condition else"]; - 104 [label="Exit when branch condition"]; + 102 [label="Enter when branch condition else"]; + 103 [label="Exit when branch condition"]; } - 105 [label="Enter when branch result"]; + 104 [label="Enter when branch result"]; subgraph cluster_25 { color=blue - 106 [label="Enter block"]; + 105 [label="Enter block"]; subgraph cluster_26 { color=blue - 107 [label="Enter when"]; + 106 [label="Enter when"]; subgraph cluster_27 { color=blue - 108 [label="Enter when branch condition "]; - 109 [label="Access variable this@R|/test_4|"]; - 110 [label="Type operator: (this@R|/test_4| !is R|B|)"]; - 111 [label="Exit when branch condition"]; + 107 [label="Enter when branch condition "]; + 108 [label="Access variable this@R|/test_4|"]; + 109 [label="Type operator: (this@R|/test_4| !is R|B|)"]; + 110 [label="Exit when branch condition"]; } subgraph cluster_28 { color=blue - 112 [label="Enter when branch condition else"]; - 113 [label="Exit when branch condition"]; + 111 [label="Enter when branch condition else"]; + 112 [label="Exit when branch condition"]; } - 114 [label="Enter when branch result"]; + 113 [label="Enter when branch result"]; subgraph cluster_29 { color=blue - 115 [label="Enter block"]; - 116 [label="Access variable this@R|/test_4|"]; + 114 [label="Enter block"]; + 115 [label="Access variable this@R|/test_4|"]; + 116 [label="Function call: this@R|/test_4|.R|/A.foo|()"]; 117 [label="Function call: this@R|/test_4|.R|/A.foo|()"]; - 118 [label="Function call: this@R|/test_4|.R|/A.foo|()"]; - 119 [label="Access variable this@R|/test_4|"]; + 118 [label="Access variable this@R|/test_4|"]; + 119 [label="Function call: this@R|/test_4|.R|/B.bar|()"]; 120 [label="Function call: this@R|/test_4|.R|/B.bar|()"]; - 121 [label="Function call: this@R|/test_4|.R|/B.bar|()"]; - 122 [label="Exit block"]; + 121 [label="Exit block"]; } - 123 [label="Exit when branch result"]; - 124 [label="Enter when branch result"]; + 122 [label="Exit when branch result"]; + 123 [label="Enter when branch result"]; subgraph cluster_30 { color=blue - 125 [label="Enter block"]; - 126 [label="Access variable this@R|/test_4|"]; - 127 [label="Function call: this@R|/test_4|.#()"]; - 128 [label="Function call: #()"]; - 129 [label="Access variable this@R|/test_4|"]; + 124 [label="Enter block"]; + 125 [label="Access variable this@R|/test_4|"]; + 126 [label="Function call: this@R|/test_4|.#()"]; + 127 [label="Function call: #()"]; + 128 [label="Access variable this@R|/test_4|"]; + 129 [label="Function call: this@R|/test_4|.R|/A.foo|()"]; 130 [label="Function call: this@R|/test_4|.R|/A.foo|()"]; - 131 [label="Function call: this@R|/test_4|.R|/A.foo|()"]; - 132 [label="Exit block"]; + 131 [label="Exit block"]; } - 133 [label="Exit when branch result"]; - 134 [label="Exit when"]; + 132 [label="Exit when branch result"]; + 133 [label="Exit when"]; } - 135 [label="Exit block"]; + 134 [label="Exit block"]; } - 136 [label="Exit when branch result"]; - 137 [label="Enter when branch result"]; + 135 [label="Exit when branch result"]; + 136 [label="Enter when branch result"]; subgraph cluster_31 { color=blue - 138 [label="Enter block"]; - 139 [label="Access variable this@R|/test_4|"]; - 140 [label="Function call: this@R|/test_4|.#()"]; - 141 [label="Function call: #()"]; - 142 [label="Access variable this@R|/test_4|"]; - 143 [label="Function call: this@R|/test_4|.#()"]; - 144 [label="Function call: #()"]; - 145 [label="Exit block"]; + 137 [label="Enter block"]; + 138 [label="Access variable this@R|/test_4|"]; + 139 [label="Function call: this@R|/test_4|.#()"]; + 140 [label="Function call: #()"]; + 141 [label="Access variable this@R|/test_4|"]; + 142 [label="Function call: this@R|/test_4|.#()"]; + 143 [label="Function call: #()"]; + 144 [label="Exit block"]; } - 146 [label="Exit when branch result"]; - 147 [label="Exit when"]; + 145 [label="Exit when branch result"]; + 146 [label="Exit when"]; } - 148 [label="Access variable this@R|/test_4|"]; - 149 [label="Function call: this@R|/test_4|.#()"]; - 150 [label="Function call: #()"]; - 151 [label="Access variable this@R|/test_4|"]; - 152 [label="Function call: this@R|/test_4|.#()"]; - 153 [label="Function call: #()"]; - 154 [label="Exit function test_4" style="filled" fillcolor=red]; + 147 [label="Access variable this@R|/test_4|"]; + 148 [label="Function call: this@R|/test_4|.#()"]; + 149 [label="Function call: #()"]; + 150 [label="Access variable this@R|/test_4|"]; + 151 [label="Function call: this@R|/test_4|.#()"]; + 152 [label="Function call: #()"]; + 153 [label="Exit function test_4" style="filled" fillcolor=red]; } + 96 -> {97}; 97 -> {98}; 98 -> {99}; 99 -> {100}; 100 -> {101}; - 101 -> {102}; - 102 -> {137 103}; + 101 -> {136 102}; + 102 -> {103}; 103 -> {104}; 104 -> {105}; 105 -> {106}; @@ -379,8 +378,8 @@ digraph implicitReceivers_kt { 107 -> {108}; 108 -> {109}; 109 -> {110}; - 110 -> {111}; - 111 -> {124 112}; + 110 -> {123 111}; + 111 -> {112}; 112 -> {113}; 113 -> {114}; 114 -> {115}; @@ -391,8 +390,8 @@ digraph implicitReceivers_kt { 119 -> {120}; 120 -> {121}; 121 -> {122}; - 122 -> {123}; - 123 -> {134}; + 122 -> {133}; + 123 -> {124}; 124 -> {125}; 125 -> {126}; 126 -> {127}; @@ -404,8 +403,8 @@ digraph implicitReceivers_kt { 132 -> {133}; 133 -> {134}; 134 -> {135}; - 135 -> {136}; - 136 -> {147}; + 135 -> {146}; + 136 -> {137}; 137 -> {138}; 138 -> {139}; 139 -> {140}; @@ -422,60 +421,59 @@ digraph implicitReceivers_kt { 150 -> {151}; 151 -> {152}; 152 -> {153}; - 153 -> {154}; subgraph cluster_32 { color=red - 155 [label="Enter function test_5" style="filled" fillcolor=red]; + 154 [label="Enter function test_5" style="filled" fillcolor=red]; subgraph cluster_33 { color=blue - 156 [label="Enter when"]; + 155 [label="Enter when"]; subgraph cluster_34 { color=blue - 157 [label="Enter when branch condition "]; - 158 [label="Access variable this@R|/test_5|"]; - 159 [label="Type operator: (this@R|/test_5| is R|kotlin/collections/List<*>|)"]; - 160 [label="Exit when branch condition"]; + 156 [label="Enter when branch condition "]; + 157 [label="Access variable this@R|/test_5|"]; + 158 [label="Type operator: (this@R|/test_5| is R|kotlin/collections/List<*>|)"]; + 159 [label="Exit when branch condition"]; } subgraph cluster_35 { color=blue - 161 [label="Enter when branch condition "]; - 162 [label="Access variable this@R|/test_5|"]; - 163 [label="Type operator: (this@R|/test_5| is R|kotlin/String|)"]; - 164 [label="Exit when branch condition"]; + 160 [label="Enter when branch condition "]; + 161 [label="Access variable this@R|/test_5|"]; + 162 [label="Type operator: (this@R|/test_5| is R|kotlin/String|)"]; + 163 [label="Exit when branch condition"]; } subgraph cluster_36 { color=blue - 165 [label="Enter when branch condition else"]; - 166 [label="Exit when branch condition"]; + 164 [label="Enter when branch condition else"]; + 165 [label="Exit when branch condition"]; } - 167 [label="Enter when branch result"]; + 166 [label="Enter when branch result"]; subgraph cluster_37 { color=blue - 168 [label="Enter block"]; - 169 [label="Const: Int(0)"]; - 170 [label="Exit block"]; + 167 [label="Enter block"]; + 168 [label="Const: Int(0)"]; + 169 [label="Exit block"]; } - 171 [label="Exit when branch result"]; - 172 [label="Enter when branch result"]; + 170 [label="Exit when branch result"]; + 171 [label="Enter when branch result"]; subgraph cluster_38 { color=blue - 173 [label="Enter block"]; - 174 [label="Access variable R|kotlin/String.length|"]; - 175 [label="Exit block"]; + 172 [label="Enter block"]; + 173 [label="Access variable R|kotlin/String.length|"]; + 174 [label="Exit block"]; } - 176 [label="Exit when branch result"]; - 177 [label="Enter when branch result"]; + 175 [label="Exit when branch result"]; + 176 [label="Enter when branch result"]; subgraph cluster_39 { color=blue - 178 [label="Enter block"]; - 179 [label="Access variable R|kotlin/collections/List.size|"]; - 180 [label="Exit block"]; + 177 [label="Enter block"]; + 178 [label="Access variable R|kotlin/collections/List.size|"]; + 179 [label="Exit block"]; } - 181 [label="Exit when branch result"]; - 182 [label="Exit when"]; + 180 [label="Exit when branch result"]; + 181 [label="Exit when"]; } - 183 [label="Jump: ^test_5 when () { + 182 [label="Jump: ^test_5 when () { (this@R|/test_5| is R|kotlin/collections/List<*>|) -> { this@R|/test_5|.R|kotlin/collections/List.size| } @@ -487,60 +485,60 @@ digraph implicitReceivers_kt { } } "]; - 184 [label="Stub" style="filled" fillcolor=gray]; - 185 [label="Exit function test_5" style="filled" fillcolor=red]; + 183 [label="Stub" style="filled" fillcolor=gray]; + 184 [label="Exit function test_5" style="filled" fillcolor=red]; } + 154 -> {155}; 155 -> {156}; 156 -> {157}; 157 -> {158}; 158 -> {159}; - 159 -> {160}; - 160 -> {177 161}; + 159 -> {176 160}; + 160 -> {161}; 161 -> {162}; 162 -> {163}; - 163 -> {164}; - 164 -> {172 165}; + 163 -> {171 164}; + 164 -> {165}; 165 -> {166}; 166 -> {167}; 167 -> {168}; 168 -> {169}; 169 -> {170}; - 170 -> {171}; - 171 -> {182}; + 170 -> {181}; + 171 -> {172}; 172 -> {173}; 173 -> {174}; 174 -> {175}; - 175 -> {176}; - 176 -> {182}; + 175 -> {181}; + 176 -> {177}; 177 -> {178}; 178 -> {179}; 179 -> {180}; 180 -> {181}; 181 -> {182}; - 182 -> {183}; - 183 -> {185}; + 182 -> {184}; + 182 -> {183} [style=dotted]; 183 -> {184} [style=dotted]; - 184 -> {185} [style=dotted]; subgraph cluster_40 { color=red - 186 [label="Enter function test_6" style="filled" fillcolor=red]; - 187 [label="Access variable this@R|/test_6|"]; - 188 [label="Type operator: (this@R|/test_6| as R|kotlin/collections/List<*>|)"]; - 189 [label="Access variable R|kotlin/collections/List.size|"]; - 190 [label="Access variable this@R|/test_6|"]; - 191 [label="Type operator: (this@R|/test_6| as R|kotlin/String|)"]; - 192 [label="Access variable R|kotlin/String.length|"]; - 193 [label="Exit function test_6" style="filled" fillcolor=red]; + 185 [label="Enter function test_6" style="filled" fillcolor=red]; + 186 [label="Access variable this@R|/test_6|"]; + 187 [label="Type operator: (this@R|/test_6| as R|kotlin/collections/List<*>|)"]; + 188 [label="Access variable R|kotlin/collections/List.size|"]; + 189 [label="Access variable this@R|/test_6|"]; + 190 [label="Type operator: (this@R|/test_6| as R|kotlin/String|)"]; + 191 [label="Access variable R|kotlin/String.length|"]; + 192 [label="Exit function test_6" style="filled" fillcolor=red]; } + 185 -> {186}; 186 -> {187}; 187 -> {188}; 188 -> {189}; 189 -> {190}; 190 -> {191}; 191 -> {192}; - 192 -> {193}; } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceivers.txt b/compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceivers.txt index 33966b98638..bafa98258a4 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceivers.txt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceivers.txt @@ -51,7 +51,7 @@ FILE: implicitReceivers.kt } public final fun test_3(a: R|kotlin/Any|, b: R|kotlin/Any|, c: R|kotlin/Any|): R|kotlin/Unit| { R|kotlin/with|(R|/a|, = wa@fun R|kotlin/Any|.(): R|kotlin/Unit| { - R|kotlin/with|(R|/b|, = wb@fun R|kotlin/Any|.(): R|kotlin/Unit| { + ^ R|kotlin/with|(R|/b|, = wb@fun R|kotlin/Any|.(): R|kotlin/Unit| { R|kotlin/with|(R|/c|, = wc@fun R|kotlin/Any|.(): R|kotlin/Unit| { (this@R|special/anonymous| as R|A|) this@R|special/anonymous|.R|/A.foo|() diff --git a/compiler/fir/resolve/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/chooseCallableReferenceDependingOnInferredReceiver.txt b/compiler/fir/resolve/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/chooseCallableReferenceDependingOnInferredReceiver.txt index de2ece8938a..8640319f75c 100644 --- a/compiler/fir/resolve/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/chooseCallableReferenceDependingOnInferredReceiver.txt +++ b/compiler/fir/resolve/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/chooseCallableReferenceDependingOnInferredReceiver.txt @@ -30,14 +30,14 @@ FILE: chooseCallableReferenceDependingOnInferredReceiver.kt ^bar R|kotlin/TODO|() } public final fun test(): R|kotlin/Unit| { - R|/myWith|(R|/A.A|(), = myWith@fun R|A|.(): R|kotlin/Unit| { + R|/myWith|(R|/A.A|(), = myWith@fun R|A|.(): R|kotlin/Nothing| { lval t1: R|A| = R|/bar|(::R|/A.foo|) lval t2: R|A| = R|/bar|(::R|/A.baz|) - R|/myWith|(R|/B.B|(), = myWith@fun R|B|.(): R|kotlin/Unit| { + ^ R|/myWith|(R|/B.B|(), = myWith@fun R|B|.(): R|kotlin/Nothing| { lval a: R|A| = R|/bar|(::R|/A.foo|) lval b: R|B| = R|/bar|(::R|/B.foo|) lval t3: R|B| = R|/bar|(::R|/B.baz|) - R|/bar|(::#) + ^ R|/bar|(::#) } ) } diff --git a/compiler/fir/resolve/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/eagerAndPostponedCallableReferences.txt b/compiler/fir/resolve/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/eagerAndPostponedCallableReferences.txt index b4db0c91619..9ea7df9597b 100644 --- a/compiler/fir/resolve/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/eagerAndPostponedCallableReferences.txt +++ b/compiler/fir/resolve/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/eagerAndPostponedCallableReferences.txt @@ -21,5 +21,5 @@ FILE: eagerAndPostponedCallableReferences.kt lval a4: R|B| = R|/foo|(::R|/multiple|, ::R|/singleB|) lval a5: R|A| = R|/foo|(::R|/singleA|, ::R|/singleA|) lval a6: R|it(A & B)| = R|/foo|(::R|/singleA|, ::R|/singleB|) - R|/foo|(::#, ::#) + R|/foo|(::#, ::#) } 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 3c4087eab0c..f1dbfed5f78 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -1417,6 +1417,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { runTest("compiler/fir/resolve/testData/resolve/problems/callableReferencesAndDefaultParameters.kt"); } + @TestMetadata("complexLambdaWithTypeVariableAsExpectedType.kt") + public void testComplexLambdaWithTypeVariableAsExpectedType() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/problems/complexLambdaWithTypeVariableAsExpectedType.kt"); + } + @TestMetadata("definitelyNotNullAndOriginalType.kt") public void testDefinitelyNotNullAndOriginalType() throws Exception { runTest("compiler/fir/resolve/testData/resolve/problems/definitelyNotNullAndOriginalType.kt"); diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java index 0c129ccd970..848935c4b76 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java @@ -1417,6 +1417,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/resolve/testData/resolve/problems/callableReferencesAndDefaultParameters.kt"); } + @TestMetadata("complexLambdaWithTypeVariableAsExpectedType.kt") + public void testComplexLambdaWithTypeVariableAsExpectedType() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/problems/complexLambdaWithTypeVariableAsExpectedType.kt"); + } + @TestMetadata("definitelyNotNullAndOriginalType.kt") public void testDefinitelyNotNullAndOriginalType() throws Exception { runTest("compiler/fir/resolve/testData/resolve/problems/definitelyNotNullAndOriginalType.kt"); diff --git a/compiler/testData/diagnostics/tests/callableReference/generic/nestedCallWithOverload.fir.fail b/compiler/testData/diagnostics/tests/callableReference/generic/nestedCallWithOverload.fir.fail deleted file mode 100644 index b00ddcff6f5..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/generic/nestedCallWithOverload.fir.fail +++ /dev/null @@ -1,8 +0,0 @@ -Failures detected in FirBodyResolveTransformerAdapter, file: /nestedCallWithOverload.fir.kt -Cause: java.lang.RuntimeException: While resolving call R?C|/baz|(R?C|/id|( = id@fun .(): { - it#.inv#() -} -), R|/id| kotlin/Unit|>( = id@fun (it: R|kotlin/Int|): R|kotlin/Unit| { - Unit -} -)) diff --git a/compiler/testData/diagnostics/tests/callableReference/generic/nestedCallWithOverload.fir.kt b/compiler/testData/diagnostics/tests/callableReference/generic/nestedCallWithOverload.fir.kt index 83713f29fc1..74317571e4d 100644 --- a/compiler/testData/diagnostics/tests/callableReference/generic/nestedCallWithOverload.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/generic/nestedCallWithOverload.fir.kt @@ -18,7 +18,7 @@ fun test() { id(id<(Int) -> Unit>(::foo)) baz<(Int) -> Unit>(id(::foo), id(id(::foo))) baz(id(::foo), id(id<(Int) -> Unit>(::foo))) - baz(id(::foo), id<(Int) -> Unit>(id(::foo))) + baz(id(::foo), id<(Int) -> Unit>(id(::foo))) baz(id { it.inv() }, id<(Int) -> Unit> { }) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/kt36044.fir.fail b/compiler/testData/diagnostics/tests/inference/kt36044.fir.fail deleted file mode 100644 index 2c348c48475..00000000000 --- a/compiler/testData/diagnostics/tests/inference/kt36044.fir.fail +++ /dev/null @@ -1,8 +0,0 @@ -Failures detected in FirBodyResolveTransformerAdapter, file: /kt36044.fir.kt -Cause: java.lang.RuntimeException: While resolving call R?C|/select|(Char(a), R?C|/map|( = map@fun (): { - ^ map@fun .(): { - String() - } - -} -)) diff --git a/compiler/testData/diagnostics/tests/inference/kt36044.fir.kt b/compiler/testData/diagnostics/tests/inference/kt36044.fir.kt deleted file mode 100644 index 8a9c12c2254..00000000000 --- a/compiler/testData/diagnostics/tests/inference/kt36044.fir.kt +++ /dev/null @@ -1,9 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -// Issue: KT-36044 - -fun select(x: A, f: () -> A) = f() -fun map(f: () -> B) = f() - -fun main() { - select('a', map { { "" } }) -} diff --git a/compiler/testData/diagnostics/tests/inference/kt36044.kt b/compiler/testData/diagnostics/tests/inference/kt36044.kt index 8a9c12c2254..c464dcbbd89 100644 --- a/compiler/testData/diagnostics/tests/inference/kt36044.kt +++ b/compiler/testData/diagnostics/tests/inference/kt36044.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER // Issue: KT-36044 diff --git a/compiler/testData/diagnostics/tests/inference/nothingType/lambdaNothingAndExpectedType.fir.kt b/compiler/testData/diagnostics/tests/inference/nothingType/lambdaNothingAndExpectedType.fir.kt index ada20a74fa9..419db4e3e21 100644 --- a/compiler/testData/diagnostics/tests/inference/nothingType/lambdaNothingAndExpectedType.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/nothingType/lambdaNothingAndExpectedType.fir.kt @@ -8,5 +8,5 @@ fun test2(f: ((String) -> Int)?) { val a0: ((Int) -> Int)? = select2({ it -> it }, null) val b0: ((Nothing) -> Unit)? = select2({ it -> it }, null) - select3({ it.length }, f, null) + select3({ it.length }, f, null) } diff --git a/compiler/testData/ir/irText/expressions/ifElseIf.fir.txt b/compiler/testData/ir/irText/expressions/ifElseIf.fir.txt index 5b26dae24d2..3dd1bb6081a 100644 --- a/compiler/testData/ir/irText/expressions/ifElseIf.fir.txt +++ b/compiler/testData/ir/irText/expressions/ifElseIf.fir.txt @@ -31,7 +31,7 @@ FILE fqName: fileName:/ifElseIf.kt BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: CONST Boolean type=kotlin.Boolean value=true - WHEN type=kotlin.Unit origin=IF + WHEN type=kotlin.Any origin=IF BRANCH if: GET_VAR 'flag: kotlin.Boolean declared in .testEmptyBranches1' type=kotlin.Boolean origin=null then: CONST Boolean type=kotlin.Boolean value=true @@ -45,14 +45,14 @@ FILE fqName: fileName:/ifElseIf.kt BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: CONST Boolean type=kotlin.Boolean value=true - WHEN type=kotlin.Unit origin=IF + WHEN type=kotlin.Any origin=IF BRANCH if: GET_VAR 'flag: kotlin.Boolean declared in .testEmptyBranches2' type=kotlin.Boolean origin=null then: CONST Boolean type=kotlin.Boolean value=true FUN name:testEmptyBranches3 visibility:public modality:FINAL <> (flag:kotlin.Boolean) returnType:kotlin.Unit VALUE_PARAMETER name:flag index:0 type:kotlin.Boolean BLOCK_BODY - WHEN type=kotlin.Unit origin=IF + WHEN type=kotlin.Any origin=IF BRANCH if: GET_VAR 'flag: kotlin.Boolean declared in .testEmptyBranches3' type=kotlin.Boolean origin=null then: BLOCK type=kotlin.Unit origin=null diff --git a/compiler/testData/ir/irText/lambdas/nonLocalReturn.fir.txt b/compiler/testData/ir/irText/lambdas/nonLocalReturn.fir.txt index a93f839a725..b7efcd27aa8 100644 --- a/compiler/testData/ir/irText/lambdas/nonLocalReturn.fir.txt +++ b/compiler/testData/ir/irText/lambdas/nonLocalReturn.fir.txt @@ -33,13 +33,14 @@ FILE fqName: fileName:/nonLocalReturn.kt block: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public final fun run (block: kotlin.Function0): R of kotlin.run [inline] declared in kotlin' type=kotlin.Nothing origin=null - : kotlin.Nothing - block: FUN_EXPR type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Nothing - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): kotlin.Nothing declared in .test3.' - GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Unit declared in .test3' + CALL 'public final fun run (block: kotlin.Function0): R of kotlin.run [inline] declared in kotlin' type=kotlin.Nothing origin=null + : kotlin.Nothing + block: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Nothing + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Nothing declared in .test3.' + GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit FUN name:testLrmFoo1 visibility:public modality:FINAL <> (ints:kotlin.collections.List) returnType:kotlin.Unit VALUE_PARAMETER name:ints index:0 type:kotlin.collections.List BLOCK_BODY