diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java index 6e6aecbdd55..3e183f414de 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java @@ -10779,6 +10779,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok runTest("compiler/testData/diagnostics/tests/inference/regressions/kt3344.kt"); } + @TestMetadata("kt34282.kt") + public void testKt34282() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/regressions/kt34282.kt"); + } + @TestMetadata("kt3496.kt") public void testKt3496() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/regressions/kt3496.kt"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt index 5cd63027552..4f063208eb2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt @@ -145,6 +145,7 @@ class DiagnosticReporterByTrackingStrategy( val candidates = ambiguityDiagnostic.candidates.map { it.candidate } reportIfNonNull(expression) { trace.report(CALLABLE_REFERENCE_RESOLUTION_AMBIGUITY.on(it.callableReference, candidates)) + trace.record(BindingContext.AMBIGUOUS_REFERENCE_TARGET, it.callableReference, candidates) } } diff --git a/compiler/testData/diagnostics/tests/callableReference/function/unresolved.kt b/compiler/testData/diagnostics/tests/callableReference/function/unresolved.kt index 6242151446c..12c944b7062 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/unresolved.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/unresolved.kt @@ -18,7 +18,7 @@ fun test2() { fun foo() {} Unresolved::foo - foo(Unresolved::foo) + foo(Unresolved::foo) foo(Unresolved::unresolved) ::unresolved } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/callableReference/generic/nestedCallWithOverload.kt b/compiler/testData/diagnostics/tests/callableReference/generic/nestedCallWithOverload.kt index 776bf38aabd..4dcb4810326 100644 --- a/compiler/testData/diagnostics/tests/callableReference/generic/nestedCallWithOverload.kt +++ b/compiler/testData/diagnostics/tests/callableReference/generic/nestedCallWithOverload.kt @@ -11,7 +11,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.kt b/compiler/testData/diagnostics/tests/callableReference/generic/resolutionGenericCallableWithNullableTypes.kt index 8b586533db6..78fddfdb2e3 100644 --- a/compiler/testData/diagnostics/tests/callableReference/generic/resolutionGenericCallableWithNullableTypes.kt +++ b/compiler/testData/diagnostics/tests/callableReference/generic/resolutionGenericCallableWithNullableTypes.kt @@ -17,7 +17,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) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/callableReference/generic/resolutionWithGenericCallable.kt b/compiler/testData/diagnostics/tests/callableReference/generic/resolutionWithGenericCallable.kt index c3ef709da74..0196e6c4812 100644 --- a/compiler/testData/diagnostics/tests/callableReference/generic/resolutionWithGenericCallable.kt +++ b/compiler/testData/diagnostics/tests/callableReference/generic/resolutionWithGenericCallable.kt @@ -5,9 +5,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) {} @@ -18,5 +18,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/ambiguityWhenNoApplicableCallableReferenceCandidate.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguityWhenNoApplicableCallableReferenceCandidate.kt index 00a756e5dc9..5f8196ddb99 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguityWhenNoApplicableCallableReferenceCandidate.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguityWhenNoApplicableCallableReferenceCandidate.kt @@ -7,5 +7,5 @@ fun foo(y: String) {} fun bar(f: (T) -> Unit) {} fun test() { - bar(::foo) + bar(::foo) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/byGenericArgType.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/byGenericArgType.kt index 450d7073b88..53f4c989346 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/byGenericArgType.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/byGenericArgType.kt @@ -8,4 +8,4 @@ fun foo(s: String) {} val x1 = ofType<() -> Unit>(::foo) val x2 = ofType<(String) -> Unit>(::foo) -val x3 = ofType<(Int) -> Unit>(::foo) \ No newline at end of file +val x3 = ofType<(Int) -> Unit>(::foo) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/chooseCallableReferenceDependingOnInferredReceiver.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/chooseCallableReferenceDependingOnInferredReceiver.kt index 67c6b461074..1c47e197547 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/chooseCallableReferenceDependingOnInferredReceiver.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/chooseCallableReferenceDependingOnInferredReceiver.kt @@ -31,7 +31,7 @@ fun test() { val t3 = bar(::baz) t3 - bar(::foo) + bar(::foo) } } } diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/eagerAndPostponedCallableReferences.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/eagerAndPostponedCallableReferences.kt index 68d8a34d62b..b1e401f2192 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/eagerAndPostponedCallableReferences.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/eagerAndPostponedCallableReferences.kt @@ -31,5 +31,5 @@ fun test() { val a6 = foo(::singleA, ::singleB) a6 - foo(::multiple, ::multiple) + foo(::multiple, ::multiple) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/withGenericFun.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/withGenericFun.kt index 709a0e84556..95d91830fd5 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/withGenericFun.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/withGenericFun.kt @@ -9,4 +9,4 @@ fun foo(s: String) {} val x1 = apply(1, ::foo) val x2 = apply("hello", ::foo) -val x3 = apply(true, ::foo) \ No newline at end of file +val x3 = apply(true, ::foo) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt32862_both.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt32862_both.kt index 1d379fe81fe..3e94df7f850 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt32862_both.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt32862_both.kt @@ -12,5 +12,5 @@ fun G.foo(vararg values: V2) = build() fun forReference(ref: Any?) {} fun test() { - forReference(G::foo) + forReference(G::foo) } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt32862_none.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt32862_none.kt index 60c0635ac66..30aa30da9b5 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt32862_none.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt32862_none.kt @@ -1,5 +1,4 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -// !LANGUAGE: +NewInference // !WITH_NEW_INFERENCE fun foo(s: String) {} @@ -8,5 +7,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.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt34282.kt new file mode 100644 index 00000000000..31e6521046d --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt34282.kt @@ -0,0 +1,10 @@ +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER + +fun bar(y: (Int) -> Int) = 1 +fun foo(x: Float) = 10f +fun foo(x: String) = "" + +fun main() { + bar(::foo) // no report about unresolved callable reference for `foo` +} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt34282.txt b/compiler/testData/diagnostics/tests/inference/regressions/kt34282.txt new file mode 100644 index 00000000000..592148b2344 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt34282.txt @@ -0,0 +1,6 @@ +package + +public fun bar(/*0*/ y: (kotlin.Int) -> kotlin.Int): kotlin.Int +public fun foo(/*0*/ x: kotlin.Float): kotlin.Float +public fun foo(/*0*/ x: kotlin.String): kotlin.String +public fun main(): kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/callableReferenceOnUnresolvedLHS.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/callableReferenceOnUnresolvedLHS.kt index 29f1c0b7e6b..3ca5c9a8160 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/callableReferenceOnUnresolvedLHS.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/callableReferenceOnUnresolvedLHS.kt @@ -6,8 +6,8 @@ class Impl : Inv class Scope(private val implClass: j.Class) { fun foo(c: Collection) { val hm = c.asSequence() - .filter(implClass::isInstance) - .map(implClass::cast) + .filter(implClass::isInstance) + .map(implClass::cast) .toSet() } } diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 70d8b830ebd..0caf95eefa4 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -10786,6 +10786,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/inference/regressions/kt3344.kt"); } + @TestMetadata("kt34282.kt") + public void testKt34282() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/regressions/kt34282.kt"); + } + @TestMetadata("kt3496.kt") public void testKt3496() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/regressions/kt3496.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index bf868974436..d4e1cf542f3 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -10781,6 +10781,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/inference/regressions/kt3344.kt"); } + @TestMetadata("kt34282.kt") + public void testKt34282() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/regressions/kt34282.kt"); + } + @TestMetadata("kt3496.kt") public void testKt3496() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/regressions/kt3496.kt");