diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java index 71e52bb0fb4..0bcda93509e 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java @@ -2628,6 +2628,16 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt12751.kt"); } + @TestMetadata("kt35887.kt") + public void testKt35887() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt35887.kt"); + } + + @TestMetadata("kt35887_simple.kt") + public void testKt35887_simple() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt35887_simple.kt"); + } + @TestMetadata("kt8596.kt") public void testKt8596() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt8596.kt"); diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceResolution.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceResolution.kt index 867413af213..961e425578f 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceResolution.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceResolution.kt @@ -85,11 +85,15 @@ fun createCallableReferenceProcessor(factory: CallableReferencesCandidateFactory return factory.createCallableProcessor(explicitReceiver) } is LHSResult.Type -> { - val static = factory.createCallableProcessor(lhsResult.qualifier) + val static = lhsResult.qualifier?.let(factory::createCallableProcessor) val unbound = factory.createCallableProcessor(lhsResult.unboundDetailedReceiver) // note that if we use PrioritizedCompositeScopeTowerProcessor then static will win over unbound members - val staticOrUnbound = SamePriorityCompositeScopeTowerProcessor(static, unbound) + val staticOrUnbound = + if (static != null) + SamePriorityCompositeScopeTowerProcessor(static, unbound) + else + unbound val asValue = lhsResult.qualifier?.classValueReceiverWithSmartCastInfo ?: return staticOrUnbound return PrioritizedCompositeScopeTowerProcessor(staticOrUnbound, factory.createCallableProcessor(asValue)) diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/kt35887.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/kt35887.fir.kt new file mode 100644 index 00000000000..5ff33d63ea2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/kt35887.fir.kt @@ -0,0 +1,13 @@ +// SKIP_TXT +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER +import kotlin.reflect.KProperty0 +import kotlin.reflect.KProperty1 + +object A + +fun property(property: KProperty1) = A + +fun property(property: KProperty0) = A + +val K.key get() : A = property(Map.Entry::key) // overload resolution ambiguity in the NI, OK in the OI diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/kt35887.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/kt35887.kt new file mode 100644 index 00000000000..5ff33d63ea2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/kt35887.kt @@ -0,0 +1,13 @@ +// SKIP_TXT +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER +import kotlin.reflect.KProperty0 +import kotlin.reflect.KProperty1 + +object A + +fun property(property: KProperty1) = A + +fun property(property: KProperty0) = A + +val K.key get() : A = property(Map.Entry::key) // overload resolution ambiguity in the NI, OK in the OI diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/kt35887_simple.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/kt35887_simple.fir.kt new file mode 100644 index 00000000000..f3aea568a45 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/kt35887_simple.fir.kt @@ -0,0 +1,9 @@ +// SKIP_TXT +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER +import kotlin.reflect.KProperty0 + +object A + +fun property0(property: KProperty0) = A +val K.key get() : A = property0(Map.Entry::key) // should be forbidden diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/kt35887_simple.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/kt35887_simple.kt new file mode 100644 index 00000000000..7ec3b81bc9c --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/kt35887_simple.kt @@ -0,0 +1,9 @@ +// SKIP_TXT +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER +import kotlin.reflect.KProperty0 + +object A + +fun property0(property: KProperty0) = A +val K.key get() : A = property0(Map.Entry::key) // should be forbidden diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 4512bf0c024..8f8016289af 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -2635,6 +2635,16 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt12751.kt"); } + @TestMetadata("kt35887.kt") + public void testKt35887() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt35887.kt"); + } + + @TestMetadata("kt35887_simple.kt") + public void testKt35887_simple() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt35887_simple.kt"); + } + @TestMetadata("kt8596.kt") public void testKt8596() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt8596.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 2dbc4d0f3a3..202d26a0f51 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -2630,6 +2630,16 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt12751.kt"); } + @TestMetadata("kt35887.kt") + public void testKt35887() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt35887.kt"); + } + + @TestMetadata("kt35887_simple.kt") + public void testKt35887_simple() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt35887_simple.kt"); + } + @TestMetadata("kt8596.kt") public void testKt8596() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/resolve/kt8596.kt");