[FIR] Report redeclaration across KMP source sets
^KT-57585 Fixed
Related tests:
- MultiPlatformIntegrationTestGenerated.testSimpleNoImplKeywordOnTopLevelFunction
- MultiPlatformIntegrationTestGenerated.testWeakIncompatibilityWithoutActualModifier
- FirPsiJsKlibDiagnosticsTestGenerated.testSignatureClash_MPP
- LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated$ResolveWithStdlib$MultiModule.testFakeOverrides
- DiagnosticCompilerTestFE10TestdataTestGenerated$Tests$Multiplatform:
- LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated$Tests$Multiplatform
- FirOldFrontendMPPDiagnosticsWithPsiTestGenerated
- FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated
- FirLibraryModuleDeclarationResolveTestGenerated.testDataClass
- org.jetbrains.kotlin.idea.k2.highlighting.K2HighlightingMetaInfoTestGenerated$Diagnostics.testDataClassFromLibrary
- org.jetbrains.fir.uast.test.FirLightClassBehaviorTest.testContainingFile
- org.jetbrains.fir.uast.test.FirLightClassBehaviorTest.testAnnotationParameterReference
- org.jetbrains.uast.test.kotlin.org.jetbrains.uast.test.kotlin.comparison.FE1LightClassBehaviorTest.testContainingFile
diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java
index 09e0a53..69e82de 100644
--- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java
+++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java
@@ -26664,6 +26664,18 @@
}
@Test
+ @TestMetadata("hmppRedeclaration.kt")
+ public void testHmppRedeclaration() {
+ runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclaration.kt");
+ }
+
+ @Test
+ @TestMetadata("hmppRedeclarationWithExpectActualPair.kt")
+ public void testHmppRedeclarationWithExpectActualPair() {
+ runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclarationWithExpectActualPair.kt");
+ }
+
+ @Test
@TestMetadata("intermediateActualHasAdditionalSupertypes.kt")
public void testIntermediateActualHasAdditionalSupertypes() {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/intermediateActualHasAdditionalSupertypes.kt");
diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java
index 5ae0538..5a9ee0d 100644
--- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java
+++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java
@@ -26664,6 +26664,18 @@
}
@Test
+ @TestMetadata("hmppRedeclaration.kt")
+ public void testHmppRedeclaration() {
+ runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclaration.kt");
+ }
+
+ @Test
+ @TestMetadata("hmppRedeclarationWithExpectActualPair.kt")
+ public void testHmppRedeclarationWithExpectActualPair() {
+ runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclarationWithExpectActualPair.kt");
+ }
+
+ @Test
@TestMetadata("intermediateActualHasAdditionalSupertypes.kt")
public void testIntermediateActualHasAdditionalSupertypes() {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/intermediateActualHasAdditionalSupertypes.kt");
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 c5f945e..bdc6b96 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
@@ -1741,6 +1741,18 @@
}
@Test
+ @TestMetadata("hmppRedeclaration.kt")
+ public void testHmppRedeclaration() {
+ runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclaration.kt");
+ }
+
+ @Test
+ @TestMetadata("hmppRedeclarationWithExpectActualPair.kt")
+ public void testHmppRedeclarationWithExpectActualPair() {
+ runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclarationWithExpectActualPair.kt");
+ }
+
+ @Test
@TestMetadata("intermediateActualHasAdditionalSupertypes.kt")
public void testIntermediateActualHasAdditionalSupertypes() {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/intermediateActualHasAdditionalSupertypes.kt");
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 71d2167..22f4146 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
@@ -1741,6 +1741,18 @@
}
@Test
+ @TestMetadata("hmppRedeclaration.kt")
+ public void testHmppRedeclaration() {
+ runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclaration.kt");
+ }
+
+ @Test
+ @TestMetadata("hmppRedeclarationWithExpectActualPair.kt")
+ public void testHmppRedeclarationWithExpectActualPair() {
+ runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclarationWithExpectActualPair.kt");
+ }
+
+ @Test
@TestMetadata("intermediateActualHasAdditionalSupertypes.kt")
public void testIntermediateActualHasAdditionalSupertypes() {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/intermediateActualHasAdditionalSupertypes.kt");
diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirConflictsHelpers.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirConflictsHelpers.kt
index 1f8db2a..1134469 100644
--- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirConflictsHelpers.kt
+++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirConflictsHelpers.kt
@@ -16,7 +16,6 @@
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.isEffectivelyFinal
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
import org.jetbrains.kotlin.fir.declarations.*
-import org.jetbrains.kotlin.fir.declarations.FirValueParameter
import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusImpl.Companion.DEFAULT_STATUS_FOR_STATUSLESS_DECLARATIONS
import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusImpl.Companion.DEFAULT_STATUS_FOR_SUSPEND_MAIN_FUNCTION
import org.jetbrains.kotlin.fir.declarations.impl.modifiersRepresentation
@@ -439,6 +438,10 @@
}
}
+private fun shouldCheckForMultiplatformRedeclaration(dependency: FirBasedSymbol<*>, dependent: FirBasedSymbol<*>): Boolean =
+ dependent.moduleData.allDependsOnDependencies.contains(dependency.moduleData) &&
+ dependency.resolvedStatus?.isExpect != true // ACTUAL_MISSING takes care of this case
+
private fun FirDeclarationCollector<FirBasedSymbol<*>>.collectTopLevelConflict(
declaration: FirBasedSymbol<*>,
declarationPresentation: String,
@@ -448,7 +451,11 @@
conflictingFile: FirFile? = null,
) {
conflictingSymbol.lazyResolveToPhase(FirResolvePhase.STATUS)
- if (conflictingSymbol == declaration || declaration.moduleData != conflictingSymbol.moduleData) return
+ if (conflictingSymbol == declaration) return
+ if (
+ declaration.moduleData != conflictingSymbol.moduleData &&
+ !shouldCheckForMultiplatformRedeclaration(declaration, conflictingSymbol)
+ ) return
val actualConflictingPresentation = conflictingPresentation ?: FirRedeclarationPresenter.represent(conflictingSymbol)
if (actualConflictingPresentation != declarationPresentation) return
val actualConflictingFile =
diff --git a/compiler/testData/diagnostics/klibSerializationTests/signatureClash_MPP.diag.txt b/compiler/testData/diagnostics/klibSerializationTests/signatureClash_MPP.diag.txt
index 3c00015..f4860a5 100644
--- a/compiler/testData/diagnostics/klibSerializationTests/signatureClash_MPP.diag.txt
+++ b/compiler/testData/diagnostics/klibSerializationTests/signatureClash_MPP.diag.txt
@@ -1,8 +1,12 @@
Module: common
+/common.kt:8:1: error: Conflicting overloads: [fun foo(): Int]
+
/common.kt:8:1: error: Platform declaration clash: The following functions have the same IR signature (/foo|foo(){}[0]):
fun foo(): kotlin.Int defined in root package
fun foo(): kotlin.String defined in root package
+/common.kt:11:1: error: Conflicting overloads: [fun bar(x: B): Int]
+
/common.kt:11:1: error: Platform declaration clash: The following functions have the same IR signature (/bar|bar(B){}[0]):
fun bar(x: B): kotlin.Int defined in root package
fun bar(x: B): kotlin.Int defined in root package
diff --git a/compiler/testData/diagnostics/klibSerializationTests/signatureClash_MPP.kt b/compiler/testData/diagnostics/klibSerializationTests/signatureClash_MPP.kt
index 0e98bd6..b1bc0d9 100644
--- a/compiler/testData/diagnostics/klibSerializationTests/signatureClash_MPP.kt
+++ b/compiler/testData/diagnostics/klibSerializationTests/signatureClash_MPP.kt
@@ -5,10 +5,10 @@
// MODULE: common
// FILE: common.kt
-<!CONFLICTING_KLIB_SIGNATURES_ERROR!>fun foo(): String = ""<!>
+<!CONFLICTING_KLIB_SIGNATURES_ERROR!><!CONFLICTING_OVERLOADS!>fun foo(): String<!> = ""<!>
expect class A
-<!CONFLICTING_KLIB_SIGNATURES_ERROR!>fun bar(x: A): Int = 2<!>
+<!CONFLICTING_KLIB_SIGNATURES_ERROR!><!CONFLICTING_OVERLOADS!>fun bar(x: A): Int<!> = 2<!>
<!CONFLICTING_KLIB_SIGNATURES_ERROR, CONFLICTING_KLIB_SIGNATURES_ERROR!>@Suppress("REDECLARATION")
val param = 0<!>
diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualTypealiasForNotExpectClass.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/actualTypealiasForNotExpectClass.fir.kt
index f0a0bff..e2b9b41 100644
--- a/compiler/testData/diagnostics/tests/multiplatform/actualTypealiasForNotExpectClass.fir.kt
+++ b/compiler/testData/diagnostics/tests/multiplatform/actualTypealiasForNotExpectClass.fir.kt
@@ -1,7 +1,7 @@
// MODULE: m1-common
// FILE: common.kt
-open class A {
+open class <!PACKAGE_OR_CLASSIFIER_REDECLARATION!>A<!> {
open fun foo(): String = "Fail"
}
expect class C1() : A
diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualTypealiasForNotExpectClass.ll.kt b/compiler/testData/diagnostics/tests/multiplatform/actualTypealiasForNotExpectClass.ll.kt
new file mode 100644
index 0000000..f0a0bff
--- /dev/null
+++ b/compiler/testData/diagnostics/tests/multiplatform/actualTypealiasForNotExpectClass.ll.kt
@@ -0,0 +1,29 @@
+// MODULE: m1-common
+// FILE: common.kt
+
+open class A {
+ open fun foo(): String = "Fail"
+}
+expect class C1() : A
+expect class C2() : A
+
+// MODULE: m2-jvm()()(m1-common)
+// FILE: A_J.java
+public class A_J {}
+
+// FILE: B_J.java
+public class B_J extends A_J {
+ public String foo() { return "O"; }
+}
+
+// FILE: C2_J.java
+public class C2_J extends B_J {
+ public String foo() { return "K"; }
+}
+
+// FILE: main.kt
+actual typealias <!ACTUAL_WITHOUT_EXPECT!>A<!> = A_J
+
+// Indirect subtyping is allowed in K2 KT-59356
+actual class C1 : B_J()
+actual typealias C2 = C2_J
diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualWithoutExpectWhenExpectIsFakeOverride.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/actualWithoutExpectWhenExpectIsFakeOverride.fir.kt
index aae03051..2242efa 100644
--- a/compiler/testData/diagnostics/tests/multiplatform/actualWithoutExpectWhenExpectIsFakeOverride.fir.kt
+++ b/compiler/testData/diagnostics/tests/multiplatform/actualWithoutExpectWhenExpectIsFakeOverride.fir.kt
@@ -1,8 +1,8 @@
// MODULE: m1-common
// FILE: common.kt
-fun foo() {}
-class Foo
+<!CONFLICTING_OVERLOADS!>fun foo()<!> {}
+class <!PACKAGE_OR_CLASSIFIER_REDECLARATION!>Foo<!>
open class Base {
open fun foo() {}
diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualWithoutExpectWhenExpectIsFakeOverride.ll.kt b/compiler/testData/diagnostics/tests/multiplatform/actualWithoutExpectWhenExpectIsFakeOverride.ll.kt
new file mode 100644
index 0000000..aae03051
--- /dev/null
+++ b/compiler/testData/diagnostics/tests/multiplatform/actualWithoutExpectWhenExpectIsFakeOverride.ll.kt
@@ -0,0 +1,33 @@
+// MODULE: m1-common
+// FILE: common.kt
+
+fun foo() {}
+class Foo
+
+open class Base {
+ open fun foo() {}
+}
+expect class Bar : Base {
+}
+
+expect open class ExpectBase {
+ open fun foo()
+}
+expect class Baz : ExpectBase
+
+// MODULE: m1-jvm()()(m1-common)
+// FILE: jvm.kt
+
+actual fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>() {}
+actual class <!ACTUAL_WITHOUT_EXPECT!>Foo<!>
+
+actual class Bar : Base() {
+ actual override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>() {}
+}
+
+actual open class ExpectBase {
+ actual open fun foo() {}
+}
+actual class Baz : ExpectBase() {
+ actual override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>() {}
+}
diff --git a/compiler/testData/diagnostics/tests/multiplatform/expectActualMainInTheSameModuleDifferentFiles.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/expectActualMainInTheSameModuleDifferentFiles.fir.kt
index bcb8c0e..8ade492 100644
--- a/compiler/testData/diagnostics/tests/multiplatform/expectActualMainInTheSameModuleDifferentFiles.fir.kt
+++ b/compiler/testData/diagnostics/tests/multiplatform/expectActualMainInTheSameModuleDifferentFiles.fir.kt
@@ -3,7 +3,7 @@
expect fun <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>main<!>()
// FILE: common2.kt
-actual fun <!ACTUAL_WITHOUT_EXPECT, EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>main<!>() {}
+<!CONFLICTING_OVERLOADS!>actual fun <!ACTUAL_WITHOUT_EXPECT!>main<!>()<!> {}
// MODULE: m1-jvm()()(m1-common)
// FILE: jvm.kt
diff --git a/compiler/testData/diagnostics/tests/multiplatform/expectActualMainInTheSameModuleDifferentFiles.ll.kt b/compiler/testData/diagnostics/tests/multiplatform/expectActualMainInTheSameModuleDifferentFiles.ll.kt
new file mode 100644
index 0000000..bcb8c0e
--- /dev/null
+++ b/compiler/testData/diagnostics/tests/multiplatform/expectActualMainInTheSameModuleDifferentFiles.ll.kt
@@ -0,0 +1,13 @@
+// MODULE: m1-common
+// FILE: common.kt
+expect fun <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>main<!>()
+
+// FILE: common2.kt
+actual fun <!ACTUAL_WITHOUT_EXPECT, EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>main<!>() {}
+
+// MODULE: m1-jvm()()(m1-common)
+// FILE: jvm.kt
+expect fun <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>main<!>()
+
+// FILE: jvm2.kt
+actual fun <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>main<!>() {}
diff --git a/compiler/testData/diagnostics/tests/multiplatform/hmpp/ambiguousActuals.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/hmpp/ambiguousActuals.fir.kt
index dff2f6f..f10067e 100644
--- a/compiler/testData/diagnostics/tests/multiplatform/hmpp/ambiguousActuals.fir.kt
+++ b/compiler/testData/diagnostics/tests/multiplatform/hmpp/ambiguousActuals.fir.kt
@@ -4,7 +4,7 @@
// MODULE: intermediate()()(common)
// TARGET_PLATFORM: Common
-actual fun foo() {}
+<!CONFLICTING_OVERLOADS!>actual fun foo()<!> {}
// MODULE: main()()(common, intermediate)
actual fun foo() {}
diff --git a/compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclaration.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclaration.fir.kt
new file mode 100644
index 0000000..7c4656c
--- /dev/null
+++ b/compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclaration.fir.kt
@@ -0,0 +1,19 @@
+// MODULE: common
+// TARGET_PLATFORM: Common
+
+class <!PACKAGE_OR_CLASSIFIER_REDECLARATION!>A<!>
+
+class <!PACKAGE_OR_CLASSIFIER_REDECLARATION!>C<!>
+
+// MODULE: intermediate()()(common)
+// TARGET_PLATFORM: Common
+
+class A
+
+class <!PACKAGE_OR_CLASSIFIER_REDECLARATION!>B<!>
+
+// MODULE: main()()(common, intermediate)
+
+class B
+
+class C
diff --git a/compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclaration.kt b/compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclaration.kt
new file mode 100644
index 0000000..5632adf
--- /dev/null
+++ b/compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclaration.kt
@@ -0,0 +1,19 @@
+// MODULE: common
+// TARGET_PLATFORM: Common
+
+class <!PACKAGE_OR_CLASSIFIER_REDECLARATION{COMMON}, PACKAGE_OR_CLASSIFIER_REDECLARATION{JVM}!>A<!>
+
+class <!PACKAGE_OR_CLASSIFIER_REDECLARATION{JVM}!>C<!>
+
+// MODULE: intermediate()()(common)
+// TARGET_PLATFORM: Common
+
+class <!PACKAGE_OR_CLASSIFIER_REDECLARATION, PACKAGE_OR_CLASSIFIER_REDECLARATION{JVM}!>A<!>
+
+class <!PACKAGE_OR_CLASSIFIER_REDECLARATION{JVM}!>B<!>
+
+// MODULE: main()()(common, intermediate)
+
+class <!PACKAGE_OR_CLASSIFIER_REDECLARATION!>B<!>
+
+class <!PACKAGE_OR_CLASSIFIER_REDECLARATION!>C<!>
diff --git a/compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclaration.ll.kt b/compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclaration.ll.kt
new file mode 100644
index 0000000..6a8158d
--- /dev/null
+++ b/compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclaration.ll.kt
@@ -0,0 +1,19 @@
+// MODULE: common
+// TARGET_PLATFORM: Common
+
+class A
+
+class C
+
+// MODULE: intermediate()()(common)
+// TARGET_PLATFORM: Common
+
+class A
+
+class B
+
+// MODULE: main()()(common, intermediate)
+
+class B
+
+class C
diff --git a/compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclarationWithExpectActualPair.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclarationWithExpectActualPair.fir.kt
new file mode 100644
index 0000000..1aa8d96
--- /dev/null
+++ b/compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclarationWithExpectActualPair.fir.kt
@@ -0,0 +1,25 @@
+// MODULE: common
+// TARGET_PLATFORM: Common
+
+expect class A
+
+expect class B
+
+class <!PACKAGE_OR_CLASSIFIER_REDECLARATION!>C<!>
+
+// MODULE: intermediate()()(common)
+// TARGET_PLATFORM: Common
+
+actual class <!PACKAGE_OR_CLASSIFIER_REDECLARATION!>A<!>
+
+class <!ACTUAL_MISSING, PACKAGE_OR_CLASSIFIER_REDECLARATION!>B<!>
+
+expect class C
+
+// MODULE: main()()(common, intermediate)
+
+class A
+
+actual class <!ACTUAL_WITHOUT_EXPECT!>B<!>
+
+actual class C
diff --git a/compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclarationWithExpectActualPair.kt b/compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclarationWithExpectActualPair.kt
new file mode 100644
index 0000000..e49df4e
--- /dev/null
+++ b/compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclarationWithExpectActualPair.kt
@@ -0,0 +1,25 @@
+// MODULE: common
+// TARGET_PLATFORM: Common
+
+expect <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE{COMMON}!>class <!AMBIGUOUS_ACTUALS{JVM}, PACKAGE_OR_CLASSIFIER_REDECLARATION{JVM}!>A<!><!>
+
+expect <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE{COMMON}!>class <!AMBIGUOUS_ACTUALS{JVM}, PACKAGE_OR_CLASSIFIER_REDECLARATION{JVM}!>B<!><!>
+
+<!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE{COMMON}!>class <!ACTUAL_MISSING{JVM}, PACKAGE_OR_CLASSIFIER_REDECLARATION{JVM}!>C<!><!>
+
+// MODULE: intermediate()()(common)
+// TARGET_PLATFORM: Common
+
+actual <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class <!PACKAGE_OR_CLASSIFIER_REDECLARATION{JVM}!>A<!><!>
+
+<!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class <!ACTUAL_MISSING{JVM}, PACKAGE_OR_CLASSIFIER_REDECLARATION{JVM}!>B<!><!>
+
+expect <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class <!AMBIGUOUS_ACTUALS{JVM}, PACKAGE_OR_CLASSIFIER_REDECLARATION{JVM}!>C<!><!>
+
+// MODULE: main()()(common, intermediate)
+
+class <!ACTUAL_MISSING, PACKAGE_OR_CLASSIFIER_REDECLARATION!>A<!>
+
+actual class <!PACKAGE_OR_CLASSIFIER_REDECLARATION!>B<!>
+
+actual class <!PACKAGE_OR_CLASSIFIER_REDECLARATION!>C<!>
diff --git a/compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclarationWithExpectActualPair.ll.kt b/compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclarationWithExpectActualPair.ll.kt
new file mode 100644
index 0000000..366f844
--- /dev/null
+++ b/compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclarationWithExpectActualPair.ll.kt
@@ -0,0 +1,25 @@
+// MODULE: common
+// TARGET_PLATFORM: Common
+
+expect class A
+
+expect class B
+
+class C
+
+// MODULE: intermediate()()(common)
+// TARGET_PLATFORM: Common
+
+actual class A
+
+class <!ACTUAL_MISSING!>B<!>
+
+expect class C
+
+// MODULE: main()()(common, intermediate)
+
+class A
+
+actual class <!ACTUAL_WITHOUT_EXPECT!>B<!>
+
+actual class C
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 d3192ad..d0464a4 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
@@ -26664,6 +26664,18 @@
}
@Test
+ @TestMetadata("hmppRedeclaration.kt")
+ public void testHmppRedeclaration() {
+ runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclaration.kt");
+ }
+
+ @Test
+ @TestMetadata("hmppRedeclarationWithExpectActualPair.kt")
+ public void testHmppRedeclarationWithExpectActualPair() {
+ runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/hmppRedeclarationWithExpectActualPair.kt");
+ }
+
+ @Test
@TestMetadata("intermediateActualHasAdditionalSupertypes.kt")
public void testIntermediateActualHasAdditionalSupertypes() {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/intermediateActualHasAdditionalSupertypes.kt");