diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java index bb6cef776e2..e4b476d0800 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java @@ -103,6 +103,18 @@ public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends Abst runTest("compiler/testData/diagnostics/tests/multiplatform/checkNoActualForExpectInLastModule.kt"); } + @Test + @TestMetadata("defaultParams_inheritanceByDelegation_negative.kt") + public void testDefaultParams_inheritanceByDelegation_negative() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/defaultParams_inheritanceByDelegation_negative.kt"); + } + + @Test + @TestMetadata("defaultParams_inheritanceByDelegation_positive.kt") + public void testDefaultParams_inheritanceByDelegation_positive() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/defaultParams_inheritanceByDelegation_positive.kt"); + } + @Test @TestMetadata("expectAbstractToString.kt") public void testExpectAbstractToString() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java index bd638ca3a4b..5b8f3ab9f7f 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java @@ -103,6 +103,18 @@ public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFi runTest("compiler/testData/diagnostics/tests/multiplatform/checkNoActualForExpectInLastModule.kt"); } + @Test + @TestMetadata("defaultParams_inheritanceByDelegation_negative.kt") + public void testDefaultParams_inheritanceByDelegation_negative() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/defaultParams_inheritanceByDelegation_negative.kt"); + } + + @Test + @TestMetadata("defaultParams_inheritanceByDelegation_positive.kt") + public void testDefaultParams_inheritanceByDelegation_positive() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/defaultParams_inheritanceByDelegation_positive.kt"); + } + @Test @TestMetadata("expectAbstractToString.kt") public void testExpectAbstractToString() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/mpp/FirExpectActualMatchingContextImpl.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/mpp/FirExpectActualMatchingContextImpl.kt index 485004ef7b1..ec23873d520 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/mpp/FirExpectActualMatchingContextImpl.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/mpp/FirExpectActualMatchingContextImpl.kt @@ -256,7 +256,7 @@ class FirExpectActualMatchingContextImpl private constructor( // Tests work even if you don't filter out fake-overrides. Filtering fake-overrides is needed because // the returned descriptors are compared by `equals`. And `equals` for fake-overrides is weird. // I didn't manage to invent a test that would check this condition - .filter { !it.isSubstitutionOrIntersectionOverride } + .filter { !it.isSubstitutionOrIntersectionOverride && it.origin != FirDeclarationOrigin.Delegated } } } } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/ClassicExpectActualMatchingContext.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/ClassicExpectActualMatchingContext.kt index 815ae891b53..e782de2a9f7 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/ClassicExpectActualMatchingContext.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/ClassicExpectActualMatchingContext.kt @@ -207,7 +207,7 @@ class ClassicExpectActualMatchingContext( // Tests work even if you don't filter out fake-overrides. Filtering fake-overrides is needed because // the returned descriptors are compared by `equals`. And `equals` for fake-overrides is weird. // I didn't manage to invent a test that would check this condition - .filter { it.kind.isReal } + .filter { it.kind != CallableMemberDescriptor.Kind.FAKE_OVERRIDE && it.kind != CallableMemberDescriptor.Kind.DELEGATION } override fun CallableSymbolMarker.isAnnotationConstructor(): Boolean { val descriptor = safeAsDescriptor() ?: return false diff --git a/compiler/testData/diagnostics/tests/multiplatform/defaultParams_inheritanceByDelegation_negative.kt b/compiler/testData/diagnostics/tests/multiplatform/defaultParams_inheritanceByDelegation_negative.kt new file mode 100644 index 00000000000..54b1e67bb71 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/defaultParams_inheritanceByDelegation_negative.kt @@ -0,0 +1,22 @@ +// FIR_IDENTICAL +// MODULE: m1-common +// FILE: common.kt +interface I { + fun f(x: Int = 5) = x +} + +expect class E : I { + override fun f(x: Int): Int +} + +expect class E2 : I { + override fun f(x: Int): Int +} + +// MODULE: m2-jvm()()(m1-common) +// FILE: jvm.kt +actual class E(i: I) : I by i + +actual class E2(i: I) : I by i { + actual override fun f(x: Int): Int = x +} diff --git a/compiler/testData/diagnostics/tests/multiplatform/defaultParams_inheritanceByDelegation_positive.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/defaultParams_inheritanceByDelegation_positive.fir.kt new file mode 100644 index 00000000000..67b8207946f --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/defaultParams_inheritanceByDelegation_positive.fir.kt @@ -0,0 +1,21 @@ +// MODULE: m1-common +// FILE: common.kt +expect class E { + fun f(x: Int): Int +} + +expect class E2 { + fun f(x: Int): Int +} + +// MODULE: m2-jvm()()(m1-common) +// FILE: jvm.kt +interface I { + fun f(x: Int = 5) = x +} + +actual class E(i: I) : I by i + +actual class E2(i: I) : I by i { + actual override fun f(x: Int) = x +} diff --git a/compiler/testData/diagnostics/tests/multiplatform/defaultParams_inheritanceByDelegation_positive.kt b/compiler/testData/diagnostics/tests/multiplatform/defaultParams_inheritanceByDelegation_positive.kt new file mode 100644 index 00000000000..bca7c9cdde7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/defaultParams_inheritanceByDelegation_positive.kt @@ -0,0 +1,21 @@ +// MODULE: m1-common +// FILE: common.kt +expect class E { + fun f(x: Int): Int +} + +expect class E2 { + fun f(x: Int): Int +} + +// MODULE: m2-jvm()()(m1-common) +// FILE: jvm.kt +interface I { + fun f(x: Int = 5) = x +} + +actual class E(i: I) : I by i + +actual class E2(i: I) : I by i { + actual override fun f(x: Int) = x +} 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 828da040dfb..b7eeea80914 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 @@ -22794,6 +22794,18 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/multiplatform/checkNoActualForExpectInLastModule.kt"); } + @Test + @TestMetadata("defaultParams_inheritanceByDelegation_negative.kt") + public void testDefaultParams_inheritanceByDelegation_negative() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/defaultParams_inheritanceByDelegation_negative.kt"); + } + + @Test + @TestMetadata("defaultParams_inheritanceByDelegation_positive.kt") + public void testDefaultParams_inheritanceByDelegation_positive() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/defaultParams_inheritanceByDelegation_positive.kt"); + } + @Test @TestMetadata("expectAbstractToString.kt") public void testExpectAbstractToString() throws Exception {