diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index d12a952a6b9..2806df1b5fd 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -2345,6 +2345,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/callableReference/noExceptionOnRedCodeWithArrayLikeCall.kt"); } + @Test + @TestMetadata("overloadResolutionWithDefaults.kt") + public void testOverloadResolutionWithDefaults() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/overloadResolutionWithDefaults.kt"); + } + @Test @TestMetadata("packageInLhs.kt") public void testPackageInLhs() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index d4d98d8ab9a..f0f302fe2cb 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java @@ -2345,6 +2345,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac runTest("compiler/testData/diagnostics/tests/callableReference/noExceptionOnRedCodeWithArrayLikeCall.kt"); } + @Test + @TestMetadata("overloadResolutionWithDefaults.kt") + public void testOverloadResolutionWithDefaults() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/overloadResolutionWithDefaults.kt"); + } + @Test @TestMetadata("packageInLhs.kt") public void testPackageInLhs() throws Exception { 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 32d103cce1b..d267eaefdba 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 @@ -105,6 +105,9 @@ class Candidate( set(value) { field = value usesSuspendConversion = value?.suspendConversionStrategy == SuspendConversionStrategy.SUSPEND_CONVERSION + if (value != null) { + numDefaults = value.defaults + } } var usesSuspendConversion: Boolean = false diff --git a/compiler/testData/diagnostics/tests/callableReference/overloadResolutionWithDefaults.kt b/compiler/testData/diagnostics/tests/callableReference/overloadResolutionWithDefaults.kt new file mode 100644 index 00000000000..944a5187c72 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/overloadResolutionWithDefaults.kt @@ -0,0 +1,29 @@ +// FIR_IDENTICAL +class ShortenReferences { + companion object { + val DEFAULT = ShortenReferences() + } + + fun process( + element: String, + elementFilter: (String) -> Int = { 10 }, + actionRunningMode: String = "" + ): String { + return "hello" + } + + fun process( + element: String, + elementFilter: (String) -> Int = { 10 }, + ): String { + return "hello" + } +} + + + +fun takeReference(block: (String) -> Unit) {} + +fun test() { + takeReference(ShortenReferences.DEFAULT::process) +} diff --git a/compiler/testData/diagnostics/tests/callableReference/overloadResolutionWithDefaults.txt b/compiler/testData/diagnostics/tests/callableReference/overloadResolutionWithDefaults.txt new file mode 100644 index 00000000000..6129dde0786 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/overloadResolutionWithDefaults.txt @@ -0,0 +1,21 @@ +package + +public fun takeReference(/*0*/ block: (kotlin.String) -> kotlin.Unit): kotlin.Unit +public fun test(): kotlin.Unit + +public final class ShortenReferences { + public constructor ShortenReferences() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final fun process(/*0*/ element: kotlin.String, /*1*/ elementFilter: (kotlin.String) -> kotlin.Int = ...): kotlin.String + public final fun process(/*0*/ element: kotlin.String, /*1*/ elementFilter: (kotlin.String) -> kotlin.Int = ..., /*2*/ actionRunningMode: kotlin.String = ...): kotlin.String + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public companion object Companion { + private constructor Companion() + public final val DEFAULT: ShortenReferences + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index b40ad5d601d..0000e1fde81 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -2351,6 +2351,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/callableReference/noExceptionOnRedCodeWithArrayLikeCall.kt"); } + @Test + @TestMetadata("overloadResolutionWithDefaults.kt") + public void testOverloadResolutionWithDefaults() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/overloadResolutionWithDefaults.kt"); + } + @Test @TestMetadata("packageInLhs.kt") public void testPackageInLhs() throws Exception { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/OverridesCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/OverridesCompletion.kt index dc9cd01cd7c..85316aa31fc 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/OverridesCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/OverridesCompletion.kt @@ -110,4 +110,4 @@ class OverridesCompletion( else -> return false } } -} \ No newline at end of file +} diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index 67dcb1679ca..70affd5242c 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -2010,6 +2010,11 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag runTest("compiler/testData/diagnostics/tests/callableReference/noExceptionOnRedCodeWithArrayLikeCall.kt"); } + @TestMetadata("overloadResolutionWithDefaults.kt") + public void testOverloadResolutionWithDefaults() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/overloadResolutionWithDefaults.kt"); + } + @TestMetadata("packageInLhs.kt") public void testPackageInLhs() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/packageInLhs.kt");