From 68f3d84e22f85ea1992fd764281c18e7ca37cf72 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Tue, 8 Sep 2020 12:01:48 +0300 Subject: [PATCH] [FIR] Use CandidateApplicability from FE 1.0 --- .../testData/resolve/arguments/default.txt | 6 +- .../arguments/defaultFromOverrides.txt | 4 +- .../testData/resolve/arguments/lambda.txt | 14 ++-- .../testData/resolve/arguments/simple.txt | 6 +- .../testData/resolve/arguments/vararg.txt | 2 +- .../testData/resolve/cfg/jumps.dot | 2 +- .../testData/resolve/cfg/jumps.txt | 2 +- .../expresssions/syntheticSmartCast.txt | 2 +- .../resolve/lambdaArgInScopeFunction.txt | 4 +- .../resolve/lambdaPropertyTypeInference.txt | 8 +-- .../testData/resolve/smartcasts/bangbang.dot | 6 +- .../testData/resolve/smartcasts/bangbang.txt | 6 +- .../smartcasts/booleans/equalsToBoolean.dot | 16 ++--- .../smartcasts/booleans/equalsToBoolean.txt | 16 ++--- .../booleans/jumpFromRhsOfOperator.dot | 12 ++-- .../booleans/jumpFromRhsOfOperator.txt | 12 ++-- .../boundSmartcastsInBranches.dot | 8 +-- .../boundSmartcastsInBranches.txt | 8 +-- .../resolve/smartcasts/equalsAndIdentity.dot | 8 +-- .../resolve/smartcasts/equalsAndIdentity.txt | 8 +-- .../resolve/smartcasts/nullability.dot | 68 +++++++++---------- .../resolve/smartcasts/nullability.txt | 56 +++++++-------- .../resolve/smartcasts/orInWhenBranch.txt | 8 +-- .../safeCalls/safeCallAndEqualityToBool.dot | 8 +-- .../safeCalls/safeCallAndEqualityToBool.txt | 8 +-- .../smartcasts/safeCalls/safeCalls.dot | 6 +- .../smartcasts/safeCalls/safeCalls.txt | 6 +- .../variables/delayedAssignment.dot | 2 +- .../variables/delayedAssignment.txt | 2 +- .../variables/smartcastAfterReassignment.dot | 2 +- .../variables/smartcastAfterReassignment.txt | 2 +- .../fromLibrary/notIsNullOrEmpty.txt | 2 +- .../good/returnsImplies/eqNotEq.txt | 2 +- .../good/returnsImplies/receivers.txt | 2 +- .../ErrorNodeDiagnosticCollectorComponent.kt | 3 +- .../jetbrains/kotlin/fir/FirCallResolver.kt | 1 + .../kotlin/fir/resolve/calls/Arguments.kt | 7 +- .../kotlin/fir/resolve/calls/Candidate.kt | 10 --- .../fir/resolve/calls/CandidateCollector.kt | 1 + .../kotlin/fir/resolve/calls/CheckerSink.kt | 1 + ...CreateFreshTypeVariableSubstitutorStage.kt | 1 + .../fir/resolve/calls/ResolutionDiagnostic.kt | 5 +- .../resolve/calls/ResolutionStageRunner.kt | 1 + .../fir/resolve/calls/ResolutionStages.kt | 7 +- .../fir/resolve/calls/TypeArgumentMapping.kt | 1 + .../fir/resolve/diagnostics/FirDiagnostics.kt | 2 +- .../inference/PostponedArgumentsAnalyzer.kt | 1 + .../fir/resolve/inference/PostponedAtoms.kt | 2 +- .../transformers/FirSyntheticCallGenerator.kt | 3 +- .../FirExpressionsResolveTransformer.kt | 1 + .../calls/tower/CandidateApplicability.kt | 6 +- .../ir/irText/expressions/kt28456a.fir.txt | 2 +- .../ir/irText/expressions/kt28456b.fir.txt | 6 +- .../api/resolver/SingleCandidateResolver.kt | 6 +- 54 files changed, 200 insertions(+), 191 deletions(-) diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/default.txt b/compiler/fir/analysis-tests/testData/resolve/arguments/default.txt index a009909f0e8..8f93c90c4d0 100644 --- a/compiler/fir/analysis-tests/testData/resolve/arguments/default.txt +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/default.txt @@ -10,12 +10,12 @@ FILE: default.kt R|/foo|(Int(1), Double(2.0)) R|/foo|(Int(1), Double(2.0), Boolean(true)) R|/foo|(Int(1), third = Boolean(true)) - #() - #(Int(0), Double(0.0), Boolean(false), String()) + #() + #(Int(0), Double(0.0), Boolean(false), String()) R|/bar|(Int(1), third = Boolean(true)) R|/bar|(Int(1), Double(2.0), Boolean(true)) R|/bar|(Int(1), Double(2.0), Boolean(true), String(my)) - #(Int(1), Boolean(true)) + #(Int(1), Boolean(true)) R|/baz|(Int(1)) R|/baz|(Int(1), vararg(String(my), String(yours))) R|/baz|(Int(1), z = Boolean(true)) diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/defaultFromOverrides.txt b/compiler/fir/analysis-tests/testData/resolve/arguments/defaultFromOverrides.txt index c4baec92736..0d6c37a9bb7 100644 --- a/compiler/fir/analysis-tests/testData/resolve/arguments/defaultFromOverrides.txt +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/defaultFromOverrides.txt @@ -22,8 +22,8 @@ FILE: defaultFromOverrides.kt public final fun foo(a: R|A|): R|kotlin/Unit| { R|/a|.R|/A.foo|() R|/a|.R|/A.foo|(Int(1)) - R|/a|.#() - R|/a|.#(String()) + R|/a|.#() + R|/a|.#(String()) R|/a|.R|/A.bar|(y = Int(1)) R|/a|.R|/A.bar|(String(), Int(2)) } diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/lambda.txt b/compiler/fir/analysis-tests/testData/resolve/arguments/lambda.txt index ef2642d0e31..41004b76565 100644 --- a/compiler/fir/analysis-tests/testData/resolve/arguments/lambda.txt +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/lambda.txt @@ -18,11 +18,11 @@ FILE: lambda.kt ^@foo Unit } ) - #(Int(1), = foo@fun (): R|kotlin/Unit| { + #(Int(1), = foo@fun (): R|kotlin/Unit| { ^@foo Unit } ) - #(f = foo@fun (): R|kotlin/Unit| { + #(f = foo@fun (): R|kotlin/Unit| { ^@foo Unit } , = foo@fun (): R|kotlin/Unit| { @@ -45,11 +45,11 @@ FILE: lambda.kt ^@bar Unit } ) - #( = bar@fun (): R|kotlin/Unit| { + #( = bar@fun (): R|kotlin/Unit| { ^@bar Unit } ) - #(bar@fun (): R|kotlin/Unit| { + #(bar@fun (): R|kotlin/Unit| { ^@bar Unit } ) @@ -61,15 +61,15 @@ FILE: lambda.kt ^@baz Unit } , Boolean(false)) - #( = baz@fun (): R|kotlin/Unit| { + #( = baz@fun (): R|kotlin/Unit| { ^@baz Unit } ) - #( = baz@fun (): R|kotlin/Unit| { + #( = baz@fun (): R|kotlin/Unit| { ^@baz Unit } ) - #(other = Boolean(false), = baz@fun (): R|kotlin/Unit| { + #(other = Boolean(false), = baz@fun (): R|kotlin/Unit| { ^@baz Unit } ) diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/simple.txt b/compiler/fir/analysis-tests/testData/resolve/arguments/simple.txt index 83f3977e7d3..73eab07c921 100644 --- a/compiler/fir/analysis-tests/testData/resolve/arguments/simple.txt +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/simple.txt @@ -7,11 +7,11 @@ FILE: simple.kt R|/foo|(Int(1), Double(2.0), fourth = String(???), third = Boolean(false)) R|/foo|(Int(1), second = Double(3.14), third = Boolean(false), fourth = String(!?)) R|/foo|(third = Boolean(false), second = Double(2.71), fourth = String(?!), first = Int(0)) - #() + #() #(Double(0.0), Boolean(false), Int(0), String()) R|/foo|(Int(1), Double(2.0), third = Boolean(true), String()) - #(second = Double(0.0), first = Int(0), fourth = String()) + #(second = Double(0.0), first = Int(0), fourth = String()) #(first = Double(0.0), second = Int(0), third = String(), fourth = Boolean(false)) #(first = Int(0), second = Double(0.0), third = Boolean(false), fourth = String(), first = Int(1)) - #(Int(0), Double(0.0), Boolean(false), foth = String()) + #(Int(0), Double(0.0), Boolean(false), foth = String()) } diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/vararg.txt b/compiler/fir/analysis-tests/testData/resolve/arguments/vararg.txt index 192c7be531e..bc2b28f3876 100644 --- a/compiler/fir/analysis-tests/testData/resolve/arguments/vararg.txt +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/vararg.txt @@ -12,5 +12,5 @@ FILE: vararg.kt #(Int(1), Int(2)) R|/bar|(Int(1), z = Boolean(true), vararg(y = *R|kotlin/arrayOf|(vararg(String(my), String(yours))))) #(Int(0), z = Boolean(false), y = String(), y = String(other)) - #(Int(0), String(), Boolean(true)) + #(Int(0), String(), Boolean(true)) } diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/jumps.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/jumps.dot index fe27f63007f..b47aa41cfbe 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/jumps.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/jumps.dot @@ -127,7 +127,7 @@ digraph jumps_kt { } 51 [label="Variable declaration: lval y: R|kotlin/Int?|"]; 52 [label="Access variable R|/y|"]; - 53 [label="Function call: R|/y|.#()"]; + 53 [label="Function call: R|/y|.#()"]; 54 [label="Exit block"]; } 55 [label="Exit function test_2" style="filled" fillcolor=red]; diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/jumps.txt b/compiler/fir/analysis-tests/testData/resolve/cfg/jumps.txt index 43ca398ba28..407edd0f5a1 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/jumps.txt +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/jumps.txt @@ -22,7 +22,7 @@ FILE: jumps.kt } } - R|/y|.#() + R|/y|.#() } public final fun test_3(x: R|kotlin/Int?|): R|kotlin/Unit| { while(Boolean(true)) { diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/syntheticSmartCast.txt b/compiler/fir/analysis-tests/testData/resolve/expresssions/syntheticSmartCast.txt index cb34d66a436..cdae761ca29 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/syntheticSmartCast.txt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/syntheticSmartCast.txt @@ -36,7 +36,7 @@ FILE: test.kt lval bar: R|kotlin/CharSequence?| = R|/x|?.{ $subj$.R|/SomeClass.bar| } when () { !=(R|/bar|, Null(null)) -> { - R|/x|.R|/SomeClass.bar|.# + R|/x|.R|/SomeClass.bar|.# } } diff --git a/compiler/fir/analysis-tests/testData/resolve/lambdaArgInScopeFunction.txt b/compiler/fir/analysis-tests/testData/resolve/lambdaArgInScopeFunction.txt index 05ea7cf3d39..d33d7c1bece 100644 --- a/compiler/fir/analysis-tests/testData/resolve/lambdaArgInScopeFunction.txt +++ b/compiler/fir/analysis-tests/testData/resolve/lambdaArgInScopeFunction.txt @@ -29,7 +29,7 @@ FILE: lambdaArgInScopeFunction.kt } ) } R|/lambda|.R|tests/_checkType/checkType| KotlinClass|>( = checkType@fun R|tests/_checkType/Inv?>|.(): R|kotlin/Unit| { - this@R|special/anonymous|.# KotlinClass?|>() + this@R|special/anonymous|.# KotlinClass?|>() } ) } @@ -50,7 +50,7 @@ FILE: lambdaArgInScopeFunction.kt } ) R|/lambda|.R|tests/_checkType/checkType| KotlinClass|>( = checkType@fun R|tests/_checkType/Inv>|.(): R|kotlin/Unit| { - this@R|special/anonymous|.# KotlinClass?|>() + this@R|special/anonymous|.# KotlinClass?|>() } ) } diff --git a/compiler/fir/analysis-tests/testData/resolve/lambdaPropertyTypeInference.txt b/compiler/fir/analysis-tests/testData/resolve/lambdaPropertyTypeInference.txt index 6d0cbee9c7d..5b1c6449801 100644 --- a/compiler/fir/analysis-tests/testData/resolve/lambdaPropertyTypeInference.txt +++ b/compiler/fir/analysis-tests/testData/resolve/lambdaPropertyTypeInference.txt @@ -29,11 +29,11 @@ FILE: KotlinClass.kt } ) R|/invalidType|.R|tests/_checkType/checkType| kotlin/Boolean|>( = checkType@fun R|tests/_checkType/Inv>|.(): R|kotlin/Unit| { - this@R|special/anonymous|.# kotlin/Boolean|>() + this@R|special/anonymous|.# kotlin/Boolean|>() } ) R|/Case1.Case1|(R|/javaClass|).R|/Case1.x|.R|tests/_checkType/checkType| kotlin/Boolean|>( = checkType@fun R|tests/_checkType/Inv>|.(): R|kotlin/Unit| { - this@R|special/anonymous|.# kotlin/Boolean|>() + this@R|special/anonymous|.# kotlin/Boolean|>() } ) } @@ -122,11 +122,11 @@ FILE: KotlinClass.kt } ) R|/invalidType|.R|tests/_checkType/checkType| kotlin/Boolean|>( = checkType@fun R|tests/_checkType/Inv>|.(): R|kotlin/Unit| { - this@R|special/anonymous|.# kotlin/Boolean|>() + this@R|special/anonymous|.# kotlin/Boolean|>() } ) R|/Case2.Case2|(R|/kotlinClass|).R|/Case2.x|.R|tests/_checkType/checkType| kotlin/Boolean|>( = checkType@fun R|tests/_checkType/Inv>|.(): R|kotlin/Unit| { - this@R|special/anonymous|.# kotlin/Boolean|>() + this@R|special/anonymous|.# kotlin/Boolean|>() } ) } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/bangbang.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/bangbang.dot index 86c29ded340..f1331c189c8 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/bangbang.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/bangbang.dot @@ -202,7 +202,7 @@ digraph bangbang_kt { 78 [label="Exit when"]; } 79 [label="Access variable R|/a|"]; - 80 [label="Function call: R|/a|.#()"]; + 80 [label="Function call: R|/a|.#()"]; 81 [label="Exit block"]; } 82 [label="Exit function test_3" style="filled" fillcolor=red]; @@ -331,14 +331,14 @@ digraph bangbang_kt { color=blue 123 [label="Enter block"]; 124 [label="Access variable R|/a|"]; - 125 [label="Function call: R|/a|.#()"]; + 125 [label="Function call: R|/a|.#()"]; 126 [label="Exit block"]; } 127 [label="Exit when branch result"]; 128 [label="Exit when"]; } 129 [label="Access variable R|/a|"]; - 130 [label="Function call: R|/a|.#()"]; + 130 [label="Function call: R|/a|.#()"]; 131 [label="Exit block"]; } 132 [label="Exit function test_5" style="filled" fillcolor=red]; diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/bangbang.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/bangbang.txt index 999c67a91a5..232de6dd6db 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/bangbang.txt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/bangbang.txt @@ -32,7 +32,7 @@ FILE: bangbang.kt } } - R|/a|.#() + R|/a|.#() } public final fun test_4(a: R|A?|, b: R|kotlin/Boolean|): R|kotlin/Unit| { when () { @@ -46,11 +46,11 @@ FILE: bangbang.kt public final fun test_5(a: R|A?|, b: R|kotlin/Boolean|): R|kotlin/Unit| { when () { R|/b| || R|/a|!!.R|/A.foo|() -> { - R|/a|.#() + R|/a|.#() } } - R|/a|.#() + R|/a|.#() } public final fun test_6(x: R|X|): R|kotlin/Unit| { R|/x|!!.R|/A.foo|() diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans/equalsToBoolean.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans/equalsToBoolean.dot index ff028b96aea..499744ca0ce 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans/equalsToBoolean.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans/equalsToBoolean.dot @@ -53,7 +53,7 @@ digraph equalsToBoolean_kt { color=blue 19 [label="Enter block"]; 20 [label="Access variable R|/b|"]; - 21 [label="Function call: R|/b|.#()"]; + 21 [label="Function call: R|/b|.#()"]; 22 [label="Exit block"]; } 23 [label="Exit when branch result"]; @@ -137,7 +137,7 @@ digraph equalsToBoolean_kt { color=blue 52 [label="Enter block"]; 53 [label="Access variable R|/b|"]; - 54 [label="Function call: R|/b|.#()"]; + 54 [label="Function call: R|/b|.#()"]; 55 [label="Exit block"]; } 56 [label="Exit when branch result"]; @@ -212,7 +212,7 @@ digraph equalsToBoolean_kt { color=blue 79 [label="Enter block"]; 80 [label="Access variable R|/b|"]; - 81 [label="Function call: R|/b|.#()"]; + 81 [label="Function call: R|/b|.#()"]; 82 [label="Exit block"]; } 83 [label="Exit when branch result"]; @@ -278,7 +278,7 @@ digraph equalsToBoolean_kt { color=blue 100 [label="Enter block"]; 101 [label="Access variable R|/b|"]; - 102 [label="Function call: R|/b|.#()"]; + 102 [label="Function call: R|/b|.#()"]; 103 [label="Exit block"]; } 104 [label="Exit when branch result"]; @@ -362,7 +362,7 @@ digraph equalsToBoolean_kt { color=blue 133 [label="Enter block"]; 134 [label="Access variable R|/b|"]; - 135 [label="Function call: R|/b|.#()"]; + 135 [label="Function call: R|/b|.#()"]; 136 [label="Exit block"]; } 137 [label="Exit when branch result"]; @@ -428,7 +428,7 @@ digraph equalsToBoolean_kt { color=blue 154 [label="Enter block"]; 155 [label="Access variable R|/b|"]; - 156 [label="Function call: R|/b|.#()"]; + 156 [label="Function call: R|/b|.#()"]; 157 [label="Exit block"]; } 158 [label="Exit when branch result"]; @@ -503,7 +503,7 @@ digraph equalsToBoolean_kt { color=blue 181 [label="Enter block"]; 182 [label="Access variable R|/b|"]; - 183 [label="Function call: R|/b|.#()"]; + 183 [label="Function call: R|/b|.#()"]; 184 [label="Exit block"]; } 185 [label="Exit when branch result"]; @@ -587,7 +587,7 @@ digraph equalsToBoolean_kt { color=blue 214 [label="Enter block"]; 215 [label="Access variable R|/b|"]; - 216 [label="Function call: R|/b|.#()"]; + 216 [label="Function call: R|/b|.#()"]; 217 [label="Exit block"]; } 218 [label="Exit when branch result"]; diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans/equalsToBoolean.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans/equalsToBoolean.txt index b110b35eae8..dcb4d6ff4a2 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans/equalsToBoolean.txt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans/equalsToBoolean.txt @@ -12,7 +12,7 @@ FILE: equalsToBoolean.kt R|/b|.R|kotlin/Boolean.not|() } else -> { - R|/b|.#() + R|/b|.#() } } @@ -20,7 +20,7 @@ FILE: equalsToBoolean.kt public final fun test_2(b: R|kotlin/Boolean?|): R|kotlin/Unit| { when () { !=(==(R|/b|, Boolean(true)), Boolean(true)) -> { - R|/b|.#() + R|/b|.#() } else -> { R|/b|.R|kotlin/Boolean.not|() @@ -31,7 +31,7 @@ FILE: equalsToBoolean.kt public final fun test_3(b: R|kotlin/Boolean?|): R|kotlin/Unit| { when () { ==(==(R|/b|, Boolean(true)), Boolean(false)) -> { - R|/b|.#() + R|/b|.#() } else -> { R|/b|.R|kotlin/Boolean.not|() @@ -45,7 +45,7 @@ FILE: equalsToBoolean.kt R|/b|.R|kotlin/Boolean.not|() } else -> { - R|/b|.#() + R|/b|.#() } } @@ -53,7 +53,7 @@ FILE: equalsToBoolean.kt public final fun test_5(b: R|kotlin/Boolean?|): R|kotlin/Unit| { when () { ==(!=(R|/b|, Boolean(true)), Boolean(true)) -> { - R|/b|.#() + R|/b|.#() } else -> { R|/b|.R|kotlin/Boolean.not|() @@ -67,7 +67,7 @@ FILE: equalsToBoolean.kt R|/b|.R|kotlin/Boolean.not|() } else -> { - R|/b|.#() + R|/b|.#() } } @@ -78,7 +78,7 @@ FILE: equalsToBoolean.kt R|/b|.R|kotlin/Boolean.not|() } else -> { - R|/b|.#() + R|/b|.#() } } @@ -86,7 +86,7 @@ FILE: equalsToBoolean.kt public final fun test_8(b: R|kotlin/Boolean?|): R|kotlin/Unit| { when () { !=(!=(R|/b|, Boolean(true)), Boolean(false)) -> { - R|/b|.#() + R|/b|.#() } else -> { R|/b|.R|kotlin/Boolean.not|() diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans/jumpFromRhsOfOperator.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans/jumpFromRhsOfOperator.dot index 9db0364683c..2bbb0e62ef3 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans/jumpFromRhsOfOperator.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans/jumpFromRhsOfOperator.dot @@ -267,7 +267,7 @@ digraph jumpFromRhsOfOperator_kt { 101 [label="Exit ||"]; } 102 [label="Access variable R|/a|"]; - 103 [label="Function call: R|/a|.#()"]; + 103 [label="Function call: R|/a|.#()"]; 104 [label="Exit block"]; } 105 [label="Exit function test_5" style="filled" fillcolor=red]; @@ -309,7 +309,7 @@ digraph jumpFromRhsOfOperator_kt { 117 [label="Exit &&"]; } 118 [label="Access variable R|/a|"]; - 119 [label="Function call: R|/a|.#()"]; + 119 [label="Function call: R|/a|.#()"]; 120 [label="Exit block"]; } 121 [label="Exit function teat_6" style="filled" fillcolor=red]; @@ -364,14 +364,14 @@ digraph jumpFromRhsOfOperator_kt { color=blue 139 [label="Enter block"]; 140 [label="Access variable R|/a|"]; - 141 [label="Function call: R|/a|.#()"]; + 141 [label="Function call: R|/a|.#()"]; 142 [label="Exit block"]; } 143 [label="Exit when branch result"]; 144 [label="Exit when"]; } 145 [label="Access variable R|/a|"]; - 146 [label="Function call: R|/a|.#()"]; + 146 [label="Function call: R|/a|.#()"]; 147 [label="Exit block"]; } 148 [label="Exit function test_7" style="filled" fillcolor=red]; @@ -437,14 +437,14 @@ digraph jumpFromRhsOfOperator_kt { color=blue 166 [label="Enter block"]; 167 [label="Access variable R|/a|"]; - 168 [label="Function call: R|/a|.#()"]; + 168 [label="Function call: R|/a|.#()"]; 169 [label="Exit block"]; } 170 [label="Exit when branch result"]; 171 [label="Exit when"]; } 172 [label="Access variable R|/a|"]; - 173 [label="Function call: R|/a|.#()"]; + 173 [label="Function call: R|/a|.#()"]; 174 [label="Exit block"]; } 175 [label="Exit function test_8" style="filled" fillcolor=red]; diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans/jumpFromRhsOfOperator.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans/jumpFromRhsOfOperator.txt index bba3fe4dde4..ee90ae4b50d 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans/jumpFromRhsOfOperator.txt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans/jumpFromRhsOfOperator.txt @@ -31,27 +31,27 @@ FILE: jumpFromRhsOfOperator.kt } public final fun test_5(a: R|A?|): R|kotlin/Unit| { ==(R|/a|, Null(null)) || throw R|java/lang/Exception.Exception|() - R|/a|.#() + R|/a|.#() } public final fun teat_6(a: R|A?|): R|kotlin/Unit| { !=(R|/a|, Null(null)) && throw R|java/lang/Exception.Exception|() - R|/a|.#() + R|/a|.#() } public final fun test_7(a: R|A?|): R|kotlin/Unit| { when () { ==(R|/a|, Null(null)) || throw R|java/lang/Exception.Exception|() -> { - R|/a|.#() + R|/a|.#() } } - R|/a|.#() + R|/a|.#() } public final fun test_8(a: R|A?|): R|kotlin/Unit| { when () { !=(R|/a|, Null(null)) && throw R|java/lang/Exception.Exception|() -> { - R|/a|.#() + R|/a|.#() } } - R|/a|.#() + R|/a|.#() } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastsInBranches.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastsInBranches.dot index 9e39d3e86d8..51bd9caff0d 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastsInBranches.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastsInBranches.dot @@ -677,7 +677,7 @@ digraph boundSmartcastsInBranches_kt { 275 [label="Access variable R|/x|"]; 276 [label="Access variable R|kotlin/String.length|"]; 277 [label="Access variable R|/y|"]; - 278 [label="Access variable #"]; + 278 [label="Access variable #"]; 279 [label="Access variable R|/z|"]; 280 [label="Access variable R|kotlin/String.length|"]; 281 [label="Exit block"]; @@ -702,11 +702,11 @@ digraph boundSmartcastsInBranches_kt { color=blue 292 [label="Enter block"]; 293 [label="Access variable R|/x|"]; - 294 [label="Access variable #"]; + 294 [label="Access variable #"]; 295 [label="Access variable R|/y|"]; 296 [label="Access variable R|kotlin/String.length|"]; 297 [label="Access variable R|/z|"]; - 298 [label="Access variable #"]; + 298 [label="Access variable #"]; 299 [label="Exit block"]; } 300 [label="Exit when branch result"]; @@ -731,7 +731,7 @@ digraph boundSmartcastsInBranches_kt { 311 [label="Access variable R|/x|"]; 312 [label="Access variable R|kotlin/String.length|"]; 313 [label="Access variable R|/y|"]; - 314 [label="Access variable #"]; + 314 [label="Access variable #"]; 315 [label="Access variable R|/z|"]; 316 [label="Access variable R|kotlin/String.length|"]; 317 [label="Exit block"]; diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastsInBranches.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastsInBranches.txt index b652bc4e03f..e9006007d22 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastsInBranches.txt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastsInBranches.txt @@ -132,23 +132,23 @@ FILE: boundSmartcastsInBranches.kt when () { !=(R|/x|, Null(null)) -> { R|/x|.R|kotlin/String.length| - R|/y|.# + R|/y|.# R|/z|.R|kotlin/String.length| } } when () { !=(R|/y|, Null(null)) -> { - R|/x|.# + R|/x|.# R|/y|.R|kotlin/String.length| - R|/z|.# + R|/z|.# } } when () { !=(R|/z|, Null(null)) -> { R|/x|.R|kotlin/String.length| - R|/y|.# + R|/y|.# R|/z|.R|kotlin/String.length| } } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/equalsAndIdentity.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/equalsAndIdentity.dot index 49f0d97b8e1..6ed56dd589d 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/equalsAndIdentity.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/equalsAndIdentity.dot @@ -136,9 +136,9 @@ digraph equalsAndIdentity_kt { color=blue 50 [label="Enter block"]; 51 [label="Access variable R|/x|"]; - 52 [label="Function call: R|/x|.#()"]; + 52 [label="Function call: R|/x|.#()"]; 53 [label="Access variable R|/y|"]; - 54 [label="Function call: R|/y|.#()"]; + 54 [label="Function call: R|/y|.#()"]; 55 [label="Exit block"]; } 56 [label="Exit when branch result"]; @@ -161,9 +161,9 @@ digraph equalsAndIdentity_kt { color=blue 66 [label="Enter block"]; 67 [label="Access variable R|/x|"]; - 68 [label="Function call: R|/x|.#()"]; + 68 [label="Function call: R|/x|.#()"]; 69 [label="Access variable R|/y|"]; - 70 [label="Function call: R|/y|.#()"]; + 70 [label="Function call: R|/y|.#()"]; 71 [label="Exit block"]; } 72 [label="Exit when branch result"]; diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/equalsAndIdentity.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/equalsAndIdentity.txt index 095a40383cf..f01b1510c72 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/equalsAndIdentity.txt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/equalsAndIdentity.txt @@ -22,15 +22,15 @@ FILE: equalsAndIdentity.kt public final fun test_2(x: R|A?|, y: R|A?|): R|kotlin/Unit| { when () { ==(R|/x|, R|/y|) -> { - R|/x|.#() - R|/y|.#() + R|/x|.#() + R|/y|.#() } } when () { ===(R|/x|, R|/y|) -> { - R|/x|.#() - R|/y|.#() + R|/x|.#() + R|/y|.#() } } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/nullability.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/nullability.dot index 113070b187a..0959bc38f09 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/nullability.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/nullability.dot @@ -278,7 +278,7 @@ digraph nullability_kt { color=blue 86 [label="Enter block"]; 87 [label="Access variable R|/x|"]; - 88 [label="Function call: R|/x|.#()"]; + 88 [label="Function call: R|/x|.#()"]; 89 [label="Exit block"]; } 90 [label="Exit when branch result"]; @@ -294,7 +294,7 @@ digraph nullability_kt { 97 [label="Exit when"]; } 98 [label="Access variable R|/x|"]; - 99 [label="Function call: R|/x|.#()"]; + 99 [label="Function call: R|/x|.#()"]; 100 [label="Exit block"]; } 101 [label="Exit function test_1" style="filled" fillcolor=red]; @@ -362,14 +362,14 @@ digraph nullability_kt { color=blue 119 [label="Enter block"]; 120 [label="Access variable R|/x|"]; - 121 [label="Function call: R|/x|.#()"]; + 121 [label="Function call: R|/x|.#()"]; 122 [label="Exit block"]; } 123 [label="Exit when branch result"]; 124 [label="Exit when"]; } 125 [label="Access variable R|/x|"]; - 126 [label="Function call: R|/x|.#()"]; + 126 [label="Function call: R|/x|.#()"]; 127 [label="Exit block"]; } 128 [label="Exit function test_2" style="filled" fillcolor=red]; @@ -531,11 +531,11 @@ digraph nullability_kt { 186 [label="Access variable R|/Q.data|"]; 187 [label="Access variable R|/q|"]; 188 [label="Access variable R|/Q.data|"]; - 189 [label="Access variable #"]; + 189 [label="Access variable #"]; 190 [label="Access variable R|/q|"]; 191 [label="Access variable R|/Q.data|"]; - 192 [label="Access variable #"]; - 193 [label="Function call: R|/q|.R|/Q.data|.#.R|kotlin/Int.inc|()"]; + 192 [label="Access variable #"]; + 193 [label="Function call: R|/q|.R|/Q.data|.#.R|kotlin/Int.inc|()"]; 194 [label="Exit block"]; } 195 [label="Exit when branch result"]; @@ -605,11 +605,11 @@ digraph nullability_kt { 218 [label="Access variable R|/Q.data|"]; 219 [label="Access variable R|/q|"]; 220 [label="Access variable R|/Q.data|"]; - 221 [label="Access variable #"]; + 221 [label="Access variable #"]; 222 [label="Access variable R|/q|"]; 223 [label="Access variable R|/Q.data|"]; - 224 [label="Access variable #"]; - 225 [label="Function call: R|/q|.R|/Q.data|.#.R|kotlin/Int.inc|()"]; + 224 [label="Access variable #"]; + 225 [label="Function call: R|/q|.R|/Q.data|.#.R|kotlin/Int.inc|()"]; 226 [label="Exit block"]; } 227 [label="Exit function test_6" style="filled" fillcolor=red]; @@ -679,11 +679,11 @@ digraph nullability_kt { 249 [label="Function call: R|/q|.R|/Q.fdata|()"]; 250 [label="Access variable R|/q|"]; 251 [label="Function call: R|/q|.R|/Q.fdata|()"]; - 252 [label="Function call: R|/q|.R|/Q.fdata|().#()"]; + 252 [label="Function call: R|/q|.R|/Q.fdata|().#()"]; 253 [label="Access variable R|/q|"]; 254 [label="Function call: R|/q|.R|/Q.fdata|()"]; - 255 [label="Function call: R|/q|.R|/Q.fdata|().#()"]; - 256 [label="Function call: R|/q|.R|/Q.fdata|().#().R|kotlin/Int.inc|()"]; + 255 [label="Function call: R|/q|.R|/Q.fdata|().#()"]; + 256 [label="Function call: R|/q|.R|/Q.fdata|().#().R|kotlin/Int.inc|()"]; 257 [label="Exit block"]; } 258 [label="Exit when branch result"]; @@ -808,7 +808,7 @@ digraph nullability_kt { 295 [label="Exit when"]; } 296 [label="Access variable R|/b|"]; - 297 [label="Function call: R|/b|.#()"]; + 297 [label="Function call: R|/b|.#()"]; subgraph cluster_73 { color=blue 298 [label="Enter when"]; @@ -833,7 +833,7 @@ digraph nullability_kt { 311 [label="Exit when"]; } 312 [label="Access variable R|/b|"]; - 313 [label="Function call: R|/b|.#()"]; + 313 [label="Function call: R|/b|.#()"]; subgraph cluster_76 { color=blue 314 [label="Enter when"]; @@ -858,7 +858,7 @@ digraph nullability_kt { 327 [label="Exit when"]; } 328 [label="Access variable R|/b|"]; - 329 [label="Function call: R|/b|.#()"]; + 329 [label="Function call: R|/b|.#()"]; subgraph cluster_79 { color=blue 330 [label="Enter when"]; @@ -883,7 +883,7 @@ digraph nullability_kt { 343 [label="Exit when"]; } 344 [label="Access variable R|/b|"]; - 345 [label="Function call: R|/b|.#()"]; + 345 [label="Function call: R|/b|.#()"]; 346 [label="Exit block"]; } 347 [label="Exit function test_9" style="filled" fillcolor=red]; @@ -979,14 +979,14 @@ digraph nullability_kt { color=blue 358 [label="Enter block"]; 359 [label="Access variable R|/b|"]; - 360 [label="Function call: R|/b|.#()"]; + 360 [label="Function call: R|/b|.#()"]; 361 [label="Exit block"]; } 362 [label="Exit when branch result"]; 363 [label="Exit when"]; } 364 [label="Access variable R|/b|"]; - 365 [label="Function call: R|/b|.#()"]; + 365 [label="Function call: R|/b|.#()"]; subgraph cluster_87 { color=blue 366 [label="Enter when"]; @@ -1004,14 +1004,14 @@ digraph nullability_kt { color=blue 374 [label="Enter block"]; 375 [label="Access variable R|/b|"]; - 376 [label="Function call: R|/b|.#()"]; + 376 [label="Function call: R|/b|.#()"]; 377 [label="Exit block"]; } 378 [label="Exit when branch result"]; 379 [label="Exit when"]; } 380 [label="Access variable R|/b|"]; - 381 [label="Function call: R|/b|.#()"]; + 381 [label="Function call: R|/b|.#()"]; subgraph cluster_90 { color=blue 382 [label="Enter when"]; @@ -1029,14 +1029,14 @@ digraph nullability_kt { color=blue 390 [label="Enter block"]; 391 [label="Access variable R|/b|"]; - 392 [label="Function call: R|/b|.#()"]; + 392 [label="Function call: R|/b|.#()"]; 393 [label="Exit block"]; } 394 [label="Exit when branch result"]; 395 [label="Exit when"]; } 396 [label="Access variable R|/b|"]; - 397 [label="Function call: R|/b|.#()"]; + 397 [label="Function call: R|/b|.#()"]; subgraph cluster_93 { color=blue 398 [label="Enter when"]; @@ -1054,14 +1054,14 @@ digraph nullability_kt { color=blue 406 [label="Enter block"]; 407 [label="Access variable R|/b|"]; - 408 [label="Function call: R|/b|.#()"]; + 408 [label="Function call: R|/b|.#()"]; 409 [label="Exit block"]; } 410 [label="Exit when branch result"]; 411 [label="Exit when"]; } 412 [label="Access variable R|/b|"]; - 413 [label="Function call: R|/b|.#()"]; + 413 [label="Function call: R|/b|.#()"]; 414 [label="Exit block"]; } 415 [label="Exit function test_10" style="filled" fillcolor=red]; @@ -1178,11 +1178,11 @@ digraph nullability_kt { 446 [label="Access variable R|/QImpl.data|"]; 447 [label="Access variable R|/q2|"]; 448 [label="Access variable R|/QImpl.data|"]; - 449 [label="Access variable #"]; + 449 [label="Access variable #"]; 450 [label="Access variable R|/q2|"]; 451 [label="Access variable R|/QImpl.data|"]; - 452 [label="Access variable #"]; - 453 [label="Function call: R|/q2|.R|/QImpl.data|.#.R|kotlin/Int.inc|()"]; + 452 [label="Access variable #"]; + 453 [label="Function call: R|/q2|.R|/QImpl.data|.#.R|kotlin/Int.inc|()"]; subgraph cluster_101 { color=blue 454 [label="Enter when"]; @@ -1319,11 +1319,11 @@ digraph nullability_kt { 500 [label="Access variable R|/QImplWithCustomGetter.data|"]; 501 [label="Access variable R|/q|"]; 502 [label="Access variable R|/QImplWithCustomGetter.data|"]; - 503 [label="Access variable #"]; + 503 [label="Access variable #"]; 504 [label="Access variable R|/q|"]; 505 [label="Access variable R|/QImplWithCustomGetter.data|"]; - 506 [label="Access variable #"]; - 507 [label="Function call: R|/q|.R|/QImplWithCustomGetter.data|.#.R|kotlin/Int.inc|()"]; + 506 [label="Access variable #"]; + 507 [label="Function call: R|/q|.R|/QImplWithCustomGetter.data|.#.R|kotlin/Int.inc|()"]; 508 [label="Exit block"]; } 509 [label="Exit when branch result"]; @@ -1402,11 +1402,11 @@ digraph nullability_kt { 534 [label="Access variable R|/QImplMutable.data|"]; 535 [label="Access variable R|/q|"]; 536 [label="Access variable R|/QImplMutable.data|"]; - 537 [label="Access variable #"]; + 537 [label="Access variable #"]; 538 [label="Access variable R|/q|"]; 539 [label="Access variable R|/QImplMutable.data|"]; - 540 [label="Access variable #"]; - 541 [label="Function call: R|/q|.R|/QImplMutable.data|.#.R|kotlin/Int.inc|()"]; + 540 [label="Access variable #"]; + 541 [label="Function call: R|/q|.R|/QImplMutable.data|.#.R|kotlin/Int.inc|()"]; 542 [label="Exit block"]; } 543 [label="Exit when branch result"]; diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/nullability.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/nullability.txt index f6675dcc8c9..bb5a8c7168b 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/nullability.txt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/nullability.txt @@ -67,23 +67,23 @@ FILE: nullability.kt R|/x|.R|/A.foo|() } else -> { - R|/x|.#() + R|/x|.#() } } - R|/x|.#() + R|/x|.#() } public final fun test_2(x: R|A?|): R|kotlin/Unit| { when () { ==(R|/x|, Null(null)) -> { - R|/x|.#() + R|/x|.#() } else -> { R|/x|.R|/A.foo|() } } - R|/x|.#() + R|/x|.#() } public final fun test_3(x: R|A?|): R|kotlin/Unit| { R|/x| ?: ^test_3 Unit @@ -102,8 +102,8 @@ FILE: nullability.kt when () { !=(R|/q|?.{ $subj$.R|/Q.data| }?.{ $subj$.R|/MyData.s| }?.{ $subj$.R|kotlin/Int.inc|() }, Null(null)) -> { R|/q|.R|/Q.data| - R|/q|.R|/Q.data|.# - R|/q|.R|/Q.data|.#.R|kotlin/Int.inc|() + R|/q|.R|/Q.data|.# + R|/q|.R|/Q.data|.#.R|kotlin/Int.inc|() } } @@ -111,15 +111,15 @@ FILE: nullability.kt public final fun test_6(q: R|Q?|): R|kotlin/Unit| { R|/q|?.{ $subj$.R|/Q.data| }?.{ $subj$.R|/MyData.s| }?.{ $subj$.R|kotlin/Int.inc|() } ?: ^test_6 Unit R|/q|.R|/Q.data| - R|/q|.R|/Q.data|.# - R|/q|.R|/Q.data|.#.R|kotlin/Int.inc|() + R|/q|.R|/Q.data|.# + R|/q|.R|/Q.data|.#.R|kotlin/Int.inc|() } public final fun test_7(q: R|Q?|): R|kotlin/Unit| { when () { !=(R|/q|?.{ $subj$.R|/Q.fdata|() }?.{ $subj$.R|/MyData.fs|() }?.{ $subj$.R|kotlin/Int.inc|() }, Null(null)) -> { R|/q|.R|/Q.fdata|() - R|/q|.R|/Q.fdata|().#() - R|/q|.R|/Q.fdata|().#().R|kotlin/Int.inc|() + R|/q|.R|/Q.fdata|().#() + R|/q|.R|/Q.fdata|().#().R|kotlin/Int.inc|() } } @@ -139,58 +139,58 @@ FILE: nullability.kt } } - R|/b|.#() + R|/b|.#() when () { ===(R|/a|, R|/b|) -> { R|/b|.R|kotlin/Int.inc|() } } - R|/b|.#() + R|/b|.#() when () { ==(R|/b|, R|/a|) -> { R|/b|.R|kotlin/Int.inc|() } } - R|/b|.#() + R|/b|.#() when () { ===(R|/b|, R|/a|) -> { R|/b|.R|kotlin/Int.inc|() } } - R|/b|.#() + R|/b|.#() } public final fun test_10(a: R|kotlin/Int?|, b: R|kotlin/Int?|): R|kotlin/Unit| { when () { ==(R|/a|, R|/b|) -> { - R|/b|.#() + R|/b|.#() } } - R|/b|.#() + R|/b|.#() when () { ===(R|/a|, R|/b|) -> { - R|/b|.#() + R|/b|.#() } } - R|/b|.#() + R|/b|.#() when () { ==(R|/b|, R|/a|) -> { - R|/b|.#() + R|/b|.#() } } - R|/b|.#() + R|/b|.#() when () { ===(R|/b|, R|/a|) -> { - R|/b|.#() + R|/b|.#() } } - R|/b|.#() + R|/b|.#() } public final fun test_11(q: R|QImpl?|, q2: R|QImpl|): R|kotlin/Unit| { when () { @@ -199,8 +199,8 @@ FILE: nullability.kt R|/q|.R|/QImpl.data|.R|/MyData.s| R|/q|.R|/QImpl.data|.R|/MyData.s|.R|kotlin/Int.inc|() R|/q2|.R|/QImpl.data| - R|/q2|.R|/QImpl.data|.# - R|/q2|.R|/QImpl.data|.#.R|kotlin/Int.inc|() + R|/q2|.R|/QImpl.data|.# + R|/q2|.R|/QImpl.data|.#.R|kotlin/Int.inc|() when () { !=(R|/q2|.R|/QImpl.data|, Null(null)) -> { R|/q2|.R|/QImpl.data|.R|/MyData.s| @@ -216,8 +216,8 @@ FILE: nullability.kt when () { !=(R|/q|?.{ $subj$.R|/QImplWithCustomGetter.data| }?.{ $subj$.R|/MyData.s| }?.{ $subj$.R|kotlin/Int.inc|() }, Null(null)) -> { R|/q|.R|/QImplWithCustomGetter.data| - R|/q|.R|/QImplWithCustomGetter.data|.# - R|/q|.R|/QImplWithCustomGetter.data|.#.R|kotlin/Int.inc|() + R|/q|.R|/QImplWithCustomGetter.data|.# + R|/q|.R|/QImplWithCustomGetter.data|.#.R|kotlin/Int.inc|() } } @@ -226,8 +226,8 @@ FILE: nullability.kt when () { !=(R|/q|?.{ $subj$.R|/QImplMutable.data| }?.{ $subj$.R|/MyData.s| }?.{ $subj$.R|kotlin/Int.inc|() }, Null(null)) -> { R|/q|.R|/QImplMutable.data| - R|/q|.R|/QImplMutable.data|.# - R|/q|.R|/QImplMutable.data|.#.R|kotlin/Int.inc|() + R|/q|.R|/QImplMutable.data|.# + R|/q|.R|/QImplMutable.data|.#.R|kotlin/Int.inc|() } } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/orInWhenBranch.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/orInWhenBranch.txt index 2c4ff649ffa..88464ef0949 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/orInWhenBranch.txt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/orInWhenBranch.txt @@ -4,7 +4,7 @@ FILE: orInWhenBranch.kt public final fun test_1(a: R|kotlin/Any?|): R|kotlin/Unit| { when (R|/a|) { ($subj$ is R|kotlin/String|) || ($subj$ is R|kotlin/Any|) -> { - R|/a|.#() + R|/a|.#() } } @@ -12,7 +12,7 @@ FILE: orInWhenBranch.kt public final fun test_2(a: R|kotlin/Any?|): R|kotlin/Unit| { when () { (R|/a| is R|kotlin/String|) || (R|/a| is R|kotlin/Any|) -> { - R|/a|.#() + R|/a|.#() } } @@ -20,7 +20,7 @@ FILE: orInWhenBranch.kt public final fun test_3(a: R|kotlin/Any?|, b: R|kotlin/Boolean|): R|kotlin/Unit| { when (R|/a|) { ($subj$ is R|kotlin/String|) || ==($subj$, R|/b|) -> { - R|/a|.#() + R|/a|.#() } } @@ -28,7 +28,7 @@ FILE: orInWhenBranch.kt public final fun test_4(a: R|kotlin/Any?|, b: R|kotlin/Boolean|): R|kotlin/Unit| { when () { (R|/a| is R|kotlin/String|) || R|/b| -> { - R|/a|.#() + R|/a|.#() } } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.dot index 9a7a3cd2378..c9e473aa55b 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.dot @@ -54,7 +54,7 @@ digraph safeCallAndEqualityToBool_kt { color=blue 21 [label="Enter block"]; 22 [label="Access variable R|/s|"]; - 23 [label="Access variable #"]; + 23 [label="Access variable #"]; 24 [label="Exit block"]; } 25 [label="Exit when branch result"]; @@ -131,7 +131,7 @@ digraph safeCallAndEqualityToBool_kt { color=blue 49 [label="Enter block"]; 50 [label="Access variable R|/s|"]; - 51 [label="Access variable #"]; + 51 [label="Access variable #"]; 52 [label="Exit block"]; } 53 [label="Exit when branch result"]; @@ -217,7 +217,7 @@ digraph safeCallAndEqualityToBool_kt { color=blue 83 [label="Enter block"]; 84 [label="Access variable R|/s|"]; - 85 [label="Access variable #"]; + 85 [label="Access variable #"]; 86 [label="Exit block"]; } 87 [label="Exit when branch result"]; @@ -294,7 +294,7 @@ digraph safeCallAndEqualityToBool_kt { color=blue 111 [label="Enter block"]; 112 [label="Access variable R|/s|"]; - 113 [label="Access variable #"]; + 113 [label="Access variable #"]; 114 [label="Exit block"]; } 115 [label="Exit when branch result"]; diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.txt index 429d819020e..fae1740aaf5 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.txt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCallAndEqualityToBool.txt @@ -8,7 +8,7 @@ FILE: safeCallAndEqualityToBool.kt R|/s|.R|kotlin/String.length| } else -> { - R|/s|.# + R|/s|.# } } @@ -19,7 +19,7 @@ FILE: safeCallAndEqualityToBool.kt R|/s|.R|kotlin/String.length| } else -> { - R|/s|.# + R|/s|.# } } @@ -27,7 +27,7 @@ FILE: safeCallAndEqualityToBool.kt public final fun test_3(s: R|kotlin/String?|): R|kotlin/Unit| { when () { !=(R|/s|?.{ $subj$.R|/check|() }, Boolean(true)) -> { - R|/s|.# + R|/s|.# } else -> { R|/s|.R|kotlin/String.length| @@ -38,7 +38,7 @@ FILE: safeCallAndEqualityToBool.kt public final fun test_4(s: R|kotlin/String?|): R|kotlin/Unit| { when () { !=(R|/s|?.{ $subj$.R|/check|() }, Boolean(false)) -> { - R|/s|.# + R|/s|.# } else -> { R|/s|.R|kotlin/String.length| diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCalls.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCalls.dot index eafca769e04..f72046cfd61 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCalls.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCalls.dot @@ -53,7 +53,7 @@ digraph safeCalls_kt { 19 [label="Function call: $subj$.R|/foo|(...)"]; 20 [label="Exit safe call"]; 21 [label="Access variable R|/x|"]; - 22 [label="Access variable #"]; + 22 [label="Access variable #"]; 23 [label="Exit block"]; } 24 [label="Exit function test" style="filled" fillcolor=red]; @@ -208,7 +208,7 @@ digraph safeCalls_kt { 78 [label="Function call: $subj$.R|/A.bool|()"]; 79 [label="Exit safe call"]; 80 [label="Access variable R|/x|"]; - 81 [label="Function call: R|/x|.#()"]; + 81 [label="Function call: R|/x|.#()"]; 82 [label="Exit block"]; } 83 [label="Exit function test_4" style="filled" fillcolor=red]; @@ -272,7 +272,7 @@ digraph safeCalls_kt { 101 [label="Function call: $subj$.R|/boo|(...)"]; 102 [label="Exit safe call"]; 103 [label="Access variable R|/x|"]; - 104 [label="Function call: R|/x|.#()"]; + 104 [label="Function call: R|/x|.#()"]; 105 [label="Exit block"]; } 106 [label="Exit function test_5" style="filled" fillcolor=red]; diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCalls.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCalls.txt index bc9fabea3a0..b45cf047799 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCalls.txt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCalls.txt @@ -6,7 +6,7 @@ FILE: safeCalls.kt } public final fun test(x: R|kotlin/String?|): R|kotlin/Unit| { R|/x|?.{ $subj$.R|/foo|(==(R|/x|.R|kotlin/String.length|, Int(1))) } - R|/x|.# + R|/x|.# } public abstract interface A : R|kotlin/Any| { public abstract fun bar(a: R|A|): R|kotlin/String| @@ -28,7 +28,7 @@ FILE: safeCalls.kt } public final fun test_4(x: R|A?|): R|kotlin/Unit| { R|/x|?.{ $subj$.R|/A.id|() }?.{ $subj$.R|/A.bool|() } - R|/x|.#() + R|/x|.#() } public final fun R|kotlin/Any?|.boo(b: R|kotlin/Boolean|): R|kotlin/Unit| { } @@ -37,5 +37,5 @@ FILE: safeCalls.kt ^test_5 Unit } ) }?.{ $subj$.R|/boo|(R|/x|.R|/A.bool|()) } - R|/x|.#() + R|/x|.#() } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/variables/delayedAssignment.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/variables/delayedAssignment.dot index 7539b0e8749..584f6c6ab63 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/variables/delayedAssignment.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/variables/delayedAssignment.dot @@ -77,7 +77,7 @@ digraph delayedAssignment_kt { 32 [label="Exit when"]; } 33 [label="Access variable R|/a|"]; - 34 [label="Function call: R|/a|.#()"]; + 34 [label="Function call: R|/a|.#()"]; 35 [label="Exit block"]; } 36 [label="Exit function test" style="filled" fillcolor=red]; diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/variables/delayedAssignment.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/variables/delayedAssignment.txt index de11a016f20..2204be47bd1 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/variables/delayedAssignment.txt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/variables/delayedAssignment.txt @@ -20,5 +20,5 @@ FILE: delayedAssignment.kt } } - R|/a|.#() + R|/a|.#() } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/variables/smartcastAfterReassignment.dot b/compiler/fir/analysis-tests/testData/resolve/smartcasts/variables/smartcastAfterReassignment.dot index 6700e45b5cd..6e88504047a 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/variables/smartcastAfterReassignment.dot +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/variables/smartcastAfterReassignment.dot @@ -103,7 +103,7 @@ digraph smartcastAfterReassignment_kt { 40 [label="Const: Null(null)"]; 41 [label="Assignment: R|/x|"]; 42 [label="Access variable R|/x|"]; - 43 [label="Access variable #"]; + 43 [label="Access variable #"]; 44 [label="Exit block"]; } 45 [label="Exit function test_3" style="filled" fillcolor=red]; diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/variables/smartcastAfterReassignment.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/variables/smartcastAfterReassignment.txt index 7925ccc6398..f357bd5eb59 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/variables/smartcastAfterReassignment.txt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/variables/smartcastAfterReassignment.txt @@ -19,5 +19,5 @@ FILE: smartcastAfterReassignment.kt R|/x| = String() R|/x|.R|kotlin/String.length| R|/x| = Null(null) - R|/x|.# + R|/x|.# } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromLibrary/notIsNullOrEmpty.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromLibrary/notIsNullOrEmpty.txt index e37ded8cbbd..53926b57e9e 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromLibrary/notIsNullOrEmpty.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromLibrary/notIsNullOrEmpty.txt @@ -10,7 +10,7 @@ FILE: notIsNullOrEmpty.kt public final fun test_2(s: R|kotlin/String?|): R|kotlin/Unit| { when () { R|/s|.R|kotlin/text/isNullOrEmpty|() -> { - R|/s|.# + R|/s|.# } else -> { R|/s|.R|kotlin/String.length| diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/returnsImplies/eqNotEq.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/returnsImplies/eqNotEq.txt index e4a4cff670f..fee93e2b06d 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/returnsImplies/eqNotEq.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/returnsImplies/eqNotEq.txt @@ -29,7 +29,7 @@ FILE: eqNotEq.kt R|/x|.R|kotlin/String.length| } else -> { - R|/x|.# + R|/x|.# } } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/returnsImplies/receivers.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/returnsImplies/receivers.txt index 281ac32ce30..6a817172d84 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/returnsImplies/receivers.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/returnsImplies/receivers.txt @@ -33,7 +33,7 @@ FILE: receivers.kt this@R|special/anonymous|.R|/myRequireNotNull|() } ) - R|/x|.#() + R|/x|.#() } public final fun test_4(x: R|A?|): R|kotlin/Unit| { R|kotlin/with|(R|/x|, = with@fun R|A?|.(): R|kotlin/Unit| { diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt index f54ac16ceae..62e7e499b3c 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt @@ -14,16 +14,15 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticFactory0 import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.fir.declarations.FirErrorFunction -import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor import org.jetbrains.kotlin.fir.diagnostics.* import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind.* import org.jetbrains.kotlin.fir.expressions.FirErrorExpression import org.jetbrains.kotlin.fir.expressions.FirErrorLoop import org.jetbrains.kotlin.fir.expressions.FirErrorResolvedQualifier import org.jetbrains.kotlin.fir.references.FirErrorNamedReference -import org.jetbrains.kotlin.fir.resolve.calls.CandidateApplicability import org.jetbrains.kotlin.fir.resolve.diagnostics.* import org.jetbrains.kotlin.fir.types.FirErrorTypeRef +import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability import org.jetbrains.kotlin.utils.addToStdlib.safeAs class ErrorNodeDiagnosticCollectorComponent(collector: AbstractDiagnosticCollector) : AbstractDiagnosticCollectorComponent(collector) { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt index ba588e1b79d..8b92af61a38 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt @@ -36,6 +36,7 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind +import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability import org.jetbrains.kotlin.types.Variance class FirCallResolver( diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Arguments.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Arguments.kt index 250e6f88ed8..b482a5ce630 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Arguments.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Arguments.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder import org.jetbrains.kotlin.resolve.calls.inference.addSubtypeConstraintIfCompatible import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition +import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability import org.jetbrains.kotlin.types.model.CaptureStatus fun Candidate.resolveArgumentExpression( @@ -264,7 +265,7 @@ private fun checkApplicabilityForArgumentType( if (expectedType == null) return if (isReceiver && isDispatch) { if (!expectedType.isNullable && argumentType.isMarkedNullable) { - sink.reportApplicability(CandidateApplicability.WRONG_RECEIVER) + sink.reportApplicability(CandidateApplicability.INAPPLICABLE_WRONG_RECEIVER) } return } @@ -277,10 +278,10 @@ private fun checkApplicabilityForArgumentType( val nullableExpectedType = expectedType.withNullability(ConeNullability.NULLABLE, sink.components.session.typeContext) if (csBuilder.addSubtypeConstraintIfCompatible(argumentType, nullableExpectedType, position)) { - sink.reportApplicability(CandidateApplicability.WRONG_RECEIVER) // TODO + sink.reportApplicability(CandidateApplicability.INAPPLICABLE_WRONG_RECEIVER) // TODO } else { csBuilder.addSubtypeConstraint(argumentType, expectedType, position) - sink.reportApplicability(CandidateApplicability.WRONG_RECEIVER) + sink.reportApplicability(CandidateApplicability.INAPPLICABLE_WRONG_RECEIVER) } } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Candidate.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Candidate.kt index 8d95d0ba856..cfe85493db8 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Candidate.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Candidate.kt @@ -73,16 +73,6 @@ data class CallInfo( ) } -enum class CandidateApplicability { - HIDDEN, - WRONG_RECEIVER, - PARAMETER_MAPPING_ERROR, - INAPPLICABLE, - SYNTHETIC_RESOLVED, - RESOLVED_LOW_PRIORITY, - RESOLVED -} - class Candidate( val symbol: AbstractFirBasedSymbol<*>, val dispatchReceiverValue: ReceiverValue?, diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CandidateCollector.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CandidateCollector.kt index 3d75aead411..9860ecd70b1 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CandidateCollector.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CandidateCollector.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.calls import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents import org.jetbrains.kotlin.fir.resolve.calls.tower.TowerGroup +import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability open class CandidateCollector( val components: BodyResolveComponents, diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CheckerSink.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CheckerSink.kt index f386417b439..e0bc198c22b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CheckerSink.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CheckerSink.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.calls import org.jetbrains.kotlin.fir.PrivateForInline import org.jetbrains.kotlin.fir.resolve.inference.InferenceComponents +import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability import kotlin.coroutines.Continuation abstract class CheckerSink { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CreateFreshTypeVariableSubstitutorStage.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CreateFreshTypeVariableSubstitutorStage.kt index 52a94184c02..9f874ffd335 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CreateFreshTypeVariableSubstitutorStage.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CreateFreshTypeVariableSubstitutorStage.kt @@ -19,6 +19,7 @@ import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.FirTypePlaceholderProjection import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemOperation import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition +import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability internal object CreateFreshTypeVariableSubstitutorStage : ResolutionStage() { override suspend fun check(candidate: Candidate, sink: CheckerSink, callInfo: CallInfo) { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionDiagnostic.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionDiagnostic.kt index 0c518e6dc68..46c5b2967e3 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionDiagnostic.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionDiagnostic.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.resolve.calls import org.jetbrains.kotlin.fir.declarations.FirFunction import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability abstract class ResolutionDiagnostic(val applicability: CandidateApplicability) @@ -20,7 +21,7 @@ class MixingNamedAndPositionArguments(override val argument: FirExpression) : In class TooManyArguments( val argument: FirExpression, val function: FirFunction<*> -) : ResolutionDiagnostic(CandidateApplicability.PARAMETER_MAPPING_ERROR) +) : ResolutionDiagnostic(CandidateApplicability.INAPPLICABLE_ARGUMENTS_MAPPING_ERROR) class NamedArgumentNotAllowed( override val argument: FirExpression, @@ -43,7 +44,7 @@ class NonVarargSpread(override val argument: FirExpression) : InapplicableArgume class NoValueForParameter( val valueParameter: FirValueParameter, val function: FirFunction<*> -) : ResolutionDiagnostic(CandidateApplicability.PARAMETER_MAPPING_ERROR) +) : ResolutionDiagnostic(CandidateApplicability.INAPPLICABLE_ARGUMENTS_MAPPING_ERROR) class NameNotFound( override val argument: FirExpression, diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStageRunner.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStageRunner.kt index 00fd9035876..9985a182ea0 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStageRunner.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStageRunner.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.fir.resolve.calls import org.jetbrains.kotlin.fir.resolve.inference.InferenceComponents +import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability import kotlin.coroutines.Continuation import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt index dab9df769f0..e42f140ef75 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemOperation import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind.* +import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability import org.jetbrains.kotlin.utils.addToStdlib.min @@ -45,17 +46,17 @@ internal object CheckExplicitReceiverConsistency : ResolutionStage() { when (receiverKind) { NO_EXPLICIT_RECEIVER -> { if (explicitReceiver != null && explicitReceiver !is FirResolvedQualifier && !explicitReceiver.isSuperReferenceExpression()) { - return sink.yieldApplicability(CandidateApplicability.WRONG_RECEIVER) + return sink.yieldApplicability(CandidateApplicability.INAPPLICABLE_WRONG_RECEIVER) } } EXTENSION_RECEIVER, DISPATCH_RECEIVER -> { if (explicitReceiver == null) { - return sink.yieldApplicability(CandidateApplicability.WRONG_RECEIVER) + return sink.yieldApplicability(CandidateApplicability.INAPPLICABLE_WRONG_RECEIVER) } } BOTH_RECEIVERS -> { if (explicitReceiver == null) { - return sink.yieldApplicability(CandidateApplicability.WRONG_RECEIVER) + return sink.yieldApplicability(CandidateApplicability.INAPPLICABLE_WRONG_RECEIVER) } // Here we should also check additional invoke receiver } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TypeArgumentMapping.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TypeArgumentMapping.kt index 6b22dfd778e..fa94f3ea348 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TypeArgumentMapping.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TypeArgumentMapping.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.resolve.calls import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRefsOwner import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.impl.FirTypePlaceholderProjection +import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability sealed class TypeArgumentMapping { abstract operator fun get(typeParameterIndex: Int): FirTypeProjection diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/FirDiagnostics.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/FirDiagnostics.kt index 69ab2cfd04f..39a779cc0ab 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/FirDiagnostics.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/FirDiagnostics.kt @@ -7,7 +7,6 @@ package org.jetbrains.kotlin.fir.resolve.diagnostics import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic import org.jetbrains.kotlin.fir.resolve.calls.Candidate -import org.jetbrains.kotlin.fir.resolve.calls.CandidateApplicability import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol @@ -16,6 +15,7 @@ import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintSystemError +import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability class ConeUnresolvedReferenceError(val name: Name? = null) : ConeDiagnostic() { override val reason: String get() = "Unresolved reference" + if (name != null) ": ${name.asString()}" else "" diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedArgumentsAnalyzer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedArgumentsAnalyzer.kt index 692784f6f9e..7b44c2abfa0 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedArgumentsAnalyzer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedArgumentsAnalyzer.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.resolve.calls.components.PostponedArgumentsAnalyzerC import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder import org.jetbrains.kotlin.resolve.calls.inference.model.CoroutinePosition import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition +import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability import org.jetbrains.kotlin.types.model.StubTypeMarker import org.jetbrains.kotlin.types.model.TypeVariableMarker import org.jetbrains.kotlin.types.model.freshTypeConstructor diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedAtoms.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedAtoms.kt index f1239df0c05..93db1f0ae7a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedAtoms.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedAtoms.kt @@ -11,7 +11,6 @@ import org.jetbrains.kotlin.fir.expressions.FirCallableReferenceAccess import org.jetbrains.kotlin.fir.expressions.FirStatement import org.jetbrains.kotlin.fir.resolve.DoubleColonLHS import org.jetbrains.kotlin.fir.resolve.calls.Candidate -import org.jetbrains.kotlin.fir.resolve.calls.CandidateApplicability import org.jetbrains.kotlin.fir.symbols.StandardClassIds import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.types.ConeKotlinType @@ -19,6 +18,7 @@ import org.jetbrains.kotlin.fir.types.ConeTypeVariable import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl import org.jetbrains.kotlin.resolve.calls.model.PostponedResolvedAtomMarker +import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability // --------------------------- Variables --------------------------- diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt index 9a5a878cb6d..620c5258744 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt @@ -6,8 +6,8 @@ package org.jetbrains.kotlin.fir.resolve.transformers import org.jetbrains.kotlin.descriptors.Modality -import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.descriptors.Visibilities +import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.builder.FirSimpleFunctionBuilder import org.jetbrains.kotlin.fir.declarations.builder.buildTypeParameter @@ -39,6 +39,7 @@ import org.jetbrains.kotlin.fir.visitors.FirTransformer import org.jetbrains.kotlin.fir.visitors.compose import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind +import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability import org.jetbrains.kotlin.types.Variance class FirSyntheticCallGenerator( diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt index edaa7211755..b9389dceab8 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt @@ -35,6 +35,7 @@ import org.jetbrains.kotlin.fir.types.builder.* import org.jetbrains.kotlin.fir.visitors.* import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : FirPartialBodyResolveTransformer(transformer) { private inline val builtinTypes: BuiltinTypes get() = session.builtinTypes diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/tower/CandidateApplicability.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/tower/CandidateApplicability.kt index bc78dba1389..a0a97eef383 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/tower/CandidateApplicability.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/tower/CandidateApplicability.kt @@ -18,7 +18,11 @@ enum class CandidateApplicability { RESOLVED_LOW_PRIORITY, RESOLVED_NEED_PRESERVE_COMPATIBILITY, // call resolved successfully, but using new features that changes resolve RESOLVED_WITH_ERROR, // call has error, but it is still successful from resolution perspective - RESOLVED, // call success or has uncompleted inference or in other words possible successful candidate + RESOLVED; // call success or has uncompleted inference or in other words possible successful candidate + + companion object { + val SYNTHETIC_RESOLVED: CandidateApplicability = RESOLVED_LOW_PRIORITY + } } val CandidateApplicability.isSuccess: Boolean diff --git a/compiler/testData/ir/irText/expressions/kt28456a.fir.txt b/compiler/testData/ir/irText/expressions/kt28456a.fir.txt index b566f6bef30..c6e6c96f163 100644 --- a/compiler/testData/ir/irText/expressions/kt28456a.fir.txt +++ b/compiler/testData/ir/irText/expressions/kt28456a.fir.txt @@ -26,7 +26,7 @@ FILE fqName: fileName:/kt28456a.kt FUN name:testSimpleAssignment visibility:public modality:FINAL <> (a:.A) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:.A BLOCK_BODY - ERROR_CALL 'Unresolved reference: #' type=kotlin.Unit + ERROR_CALL 'Unresolved reference: #' type=kotlin.Unit CONST Int type=kotlin.Int value=1 CONST Int type=kotlin.Int value=2 CONST Int type=kotlin.Int value=3 diff --git a/compiler/testData/ir/irText/expressions/kt28456b.fir.txt b/compiler/testData/ir/irText/expressions/kt28456b.fir.txt index c745d402ec4..31d2764642e 100644 --- a/compiler/testData/ir/irText/expressions/kt28456b.fir.txt +++ b/compiler/testData/ir/irText/expressions/kt28456b.fir.txt @@ -47,7 +47,7 @@ FILE fqName: fileName:/kt28456b.kt FUN name:testSimpleAssignment visibility:public modality:FINAL <> (a:.A) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:.A BLOCK_BODY - ERROR_CALL 'Unresolved reference: #' type=kotlin.Unit + ERROR_CALL 'Unresolved reference: #' type=kotlin.Unit CONST Int type=kotlin.Int value=1 CONST Int type=kotlin.Int value=0 FUN name:testPostfixIncrement visibility:public modality:FINAL <> (a:.A) returnType:kotlin.Int @@ -59,7 +59,7 @@ FILE fqName: fileName:/kt28456b.kt CALL 'public final fun get (i: kotlin.Int, a: kotlin.Int, b: kotlin.Int, c: kotlin.Int, d: kotlin.Int): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null $receiver: GET_VAR 'a: .A declared in .testPostfixIncrement' type=.A origin=null i: CONST Int type=kotlin.Int value=1 - ERROR_CALL 'Unresolved reference: #' type=kotlin.Unit + ERROR_CALL 'Unresolved reference: #' type=kotlin.Unit CONST Int type=kotlin.Int value=1 CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null $this: GET_VAR 'val tmp_0: kotlin.Int [val] declared in .testPostfixIncrement' type=kotlin.Int origin=null @@ -72,7 +72,7 @@ FILE fqName: fileName:/kt28456b.kt GET_VAR 'a: .A declared in .testCompoundAssignment' type=.A origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Int [val] CONST Int type=kotlin.Int value=1 - ERROR_CALL 'Unresolved reference: #' type=kotlin.Unit + ERROR_CALL 'Unresolved reference: #' type=kotlin.Unit GET_VAR 'val tmp_2: kotlin.Int [val] declared in .testCompoundAssignment' type=kotlin.Int origin=null CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null $this: CALL 'public final fun get (i: kotlin.Int, a: kotlin.Int, b: kotlin.Int, c: kotlin.Int, d: kotlin.Int): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/resolver/SingleCandidateResolver.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/resolver/SingleCandidateResolver.kt index 34ffd5dab69..fe00a34bc98 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/resolver/SingleCandidateResolver.kt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/resolver/SingleCandidateResolver.kt @@ -8,7 +8,10 @@ package org.jetbrains.kotlin.idea.fir.low.level.api.resolver import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.declarations.FirResolvePhase -import org.jetbrains.kotlin.fir.expressions.* +import org.jetbrains.kotlin.fir.expressions.FirArgumentList +import org.jetbrains.kotlin.fir.expressions.FirEmptyArgumentList +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirFunctionCall import org.jetbrains.kotlin.fir.expressions.builder.buildFunctionCall import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.calls.* @@ -18,6 +21,7 @@ import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirBodyResolve import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability class SingleCandidateResolver( private val firSession: FirSession,