diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/companions.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/companions.fir.txt index 9faabb0c7f3..76307f59c44 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/companions.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/companions.fir.txt @@ -57,6 +57,6 @@ FILE: main.kt R|/foo2|(Q|KotlinClass|::R|/JavaClass.bar|) R|/foo3|(Q|KotlinClass|::R|/JavaClass.bar|) R|/foo1|(Q|KotlinClass2|::R|/KotlinClass2.Companion.bar|) - R|/foo2#|(Q|KotlinClass2|::#) + R|/foo2#|(Q|KotlinClass2|::#) R|/foo3|(Q|KotlinClass2|::R|/KotlinClass2.Companion.bar|) } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/companions.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/companions.kt index 5fa55829b48..391db3d9469 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/companions.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/companions.kt @@ -40,7 +40,7 @@ fun main() { foo1(KotlinClass2::bar) // Type mismatch - foo2(KotlinClass2::bar) + foo2(KotlinClass2::bar) foo3(KotlinClass2::bar) } 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 881f87dd0cd..a13cae46c86 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt @@ -402,7 +402,7 @@ class FirCallResolver( } val (reducedCandidates, newApplicability) = reduceCandidates(result, callableReferenceAccess.explicitReceiver) - val isSuccess = reducedCandidates.isNotEmpty() && reducedCandidates.all { it.isSuccessful } + val nonEmptyAndAllSuccessful = reducedCandidates.isNotEmpty() && reducedCandidates.all { it.isSuccessful } val applicability = newApplicability ?: result.currentApplicability (callableReferenceAccess.explicitReceiver as? FirResolvedQualifier)?.replaceResolvedToCompanionObject( @@ -412,14 +412,16 @@ class FirCallResolver( resolvedCallableReferenceAtom.hasBeenResolvedOnce = true when { - !isSuccess -> { + !nonEmptyAndAllSuccessful -> { val errorReference = buildReferenceWithErrorCandidate( info, when { applicability == CandidateApplicability.K2_UNSUPPORTED -> { - val unsupportedResolutionDiagnostic = reducedCandidates.firstOrNull()?.diagnostics?.firstOrNull() as? Unsupported + val unsupportedResolutionDiagnostic = + reducedCandidates.firstOrNull()?.diagnostics?.firstOrNull() as? Unsupported ConeUnsupported(unsupportedResolutionDiagnostic?.message ?: "", unsupportedResolutionDiagnostic?.source) } + reducedCandidates.size > 1 -> ConeAmbiguityError(info.name, applicability, reducedCandidates) reducedCandidates.size == 1 -> createConeDiagnosticForCandidateWithError(applicability, reducedCandidates.single()) else -> ConeUnresolvedReferenceError(info.name) }, diff --git a/compiler/testData/diagnostics/tests/callableReference/generic/nestedCallWithOverload.fir.kt b/compiler/testData/diagnostics/tests/callableReference/generic/nestedCallWithOverload.fir.kt index 1559fb0901c..47751a72940 100644 --- a/compiler/testData/diagnostics/tests/callableReference/generic/nestedCallWithOverload.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/generic/nestedCallWithOverload.fir.kt @@ -10,7 +10,7 @@ fun test() { val x2: (Int) -> Unit = baz(id(::foo), ::foo) val x3: (Int) -> Unit = baz(id(::foo), id(id(::foo))) val x4: (String) -> Unit = baz(id(::foo), id(id(::foo))) - val x5: (Double) -> Unit = baz(id(::foo), id(id(::foo))) + val x5: (Double) -> Unit = baz(id(::foo), id(id(::foo))) id<(Int) -> Unit>(id(id(::foo))) diff --git a/compiler/testData/diagnostics/tests/callableReference/generic/resolutionGenericCallableWithNullableTypes.fir.kt b/compiler/testData/diagnostics/tests/callableReference/generic/resolutionGenericCallableWithNullableTypes.fir.kt index 3d196b15c58..066ac91292e 100644 --- a/compiler/testData/diagnostics/tests/callableReference/generic/resolutionGenericCallableWithNullableTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/generic/resolutionGenericCallableWithNullableTypes.fir.kt @@ -16,7 +16,7 @@ fun test1() { baz(::foo).checkType { _() } baz(::foo).checkType { _() } - val b1: Int = baz(::foo) - val b2: String = baz(::foo) - val b3: Boolean = baz(::foo) + val b1: Int = baz(::foo) + val b2: String = baz(::foo) + val b3: Boolean = baz(::foo) } diff --git a/compiler/testData/diagnostics/tests/callableReference/generic/resolutionWithGenericCallable.fir.kt b/compiler/testData/diagnostics/tests/callableReference/generic/resolutionWithGenericCallable.fir.kt index bd993580161..725b51f54a5 100644 --- a/compiler/testData/diagnostics/tests/callableReference/generic/resolutionWithGenericCallable.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/generic/resolutionWithGenericCallable.fir.kt @@ -4,9 +4,9 @@ fun test() { val a1: Array Double> = arrayOf(Double::plus, Double::minus) val a2: Array Double> = arrayOf(Double::plus, Double::minus) - val a3: Array Double> = arrayOf(Double::plus, Double::minus) - val a4: Array Double> = arrayOf(Int::plus, Double::minus) - val a5: Array Double> = arrayOf(Double::plus, Int::minus) + val a3: Array Double> = arrayOf(Double::plus, Double::minus) + val a4: Array Double> = arrayOf(Int::plus, Double::minus) + val a5: Array Double> = arrayOf(Double::plus, Int::minus) } fun foo(x: Int) {} @@ -17,5 +17,5 @@ fun bar(x: T, f: (T) -> Unit) {} fun test2() { bar(1, ::foo) bar("", ::foo) - bar(1.0, ::foo) + bar(1.0, ::foo) } diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/byGenericArgType.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/byGenericArgType.fir.kt index e760d3cd14a..a0272aba1db 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/byGenericArgType.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/byGenericArgType.fir.kt @@ -7,4 +7,4 @@ fun foo(s: String) {} val x1 = ofType<() -> Unit>(::foo) val x2 = ofType<(String) -> Unit>(::foo) -val x3 = ofType<(Int) -> Unit>(::foo) +val x3 = ofType<(Int) -> Unit>(::foo) diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/withGenericFun.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/withGenericFun.fir.kt index bf21c82340b..0fc0852c551 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/withGenericFun.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/withGenericFun.fir.kt @@ -8,4 +8,4 @@ fun foo(s: String) {} val x1 = apply(1, ::foo) val x2 = apply("hello", ::foo) -val x3 = apply(true, ::foo) +val x3 = apply(true, ::foo) diff --git a/compiler/testData/diagnostics/tests/inference/kt39220.fir.kt b/compiler/testData/diagnostics/tests/inference/kt39220.fir.kt index adcf17020ab..f5064f378c7 100644 --- a/compiler/testData/diagnostics/tests/inference/kt39220.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/kt39220.fir.kt @@ -27,22 +27,22 @@ interface Foo { // CR on property with to receivers are forbidden fun test() { // with LHS and property - bar8(Foo::x1) - bar8(Foo::x1) - bar8(Foo::x1) + bar8(Foo::x1) + bar8(Foo::x1) + bar8(Foo::x1) // with LHS and mutable property - bar8(Foo::x2) - bar8(Foo::x2) - bar8(Foo::x2) + bar8(Foo::x2) + bar8(Foo::x2) + bar8(Foo::x2) // with LHS and propery + mutable property (mixed) - bar8(Foo::x3) - bar8(Foo::x3) - bar8(Foo::x3) - bar9(Foo::x3) - bar9(Foo::x3) - bar9(Foo::x3) + bar8(Foo::x3) + bar8(Foo::x3) + bar8(Foo::x3) + bar9(Foo::x3) + bar9(Foo::x3) + bar9(Foo::x3) } } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt32862_none.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt32862_none.fir.kt index f144f960a93..c2d43950268 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt32862_none.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt32862_none.fir.kt @@ -6,5 +6,5 @@ fun foo(i: Long) {} fun bar(f: (Boolean) -> Unit) {} fun test() { - bar(::foo) + bar(::foo) } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt34282.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt34282.fir.kt index 13d9040ee94..6f011cf31aa 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt34282.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt34282.fir.kt @@ -5,5 +5,5 @@ fun foo(x: Float) = 10f fun foo(x: String) = "" fun main() { - bar(::foo) // no report about unresolved callable reference for `foo` + bar(::foo) // no report about unresolved callable reference for `foo` } diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/bidirectional-resolution-for-callable-calls/p-3/neg/1.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/bidirectional-resolution-for-callable-calls/p-3/neg/1.1.fir.kt index 0148704fe37..4269205fbd0 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/bidirectional-resolution-for-callable-calls/p-3/neg/1.1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/bidirectional-resolution-for-callable-calls/p-3/neg/1.1.fir.kt @@ -25,7 +25,7 @@ class Case1() { } fun case() { - Companion(::x) + Companion(::x) } val x = "" @@ -41,7 +41,7 @@ class Case2() { } fun case() { - Companion(::x) + Companion(::x) } val x = C()