[Tests] Add diagnostic tests for sealed class inheritors

- Fix unrelated resolution errors in an existing test
- Add separate test for sealed classes and interfaces in HMPP projects,
located in different source sets

KT-64919
This commit is contained in:
Pavel Kirpichenkov
2024-01-31 17:51:43 +02:00
committed by Space Team
parent 3db7df6898
commit 3dede06d51
11 changed files with 184 additions and 24 deletions
@@ -26632,12 +26632,30 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/intermediateWithActualAndExpect.kt");
}
@Test
@TestMetadata("sealedInheritorsCorrectExpect.kt")
public void testSealedInheritorsCorrectExpect() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsCorrectExpect.kt");
}
@Test
@TestMetadata("sealedInheritorsInComplexModuleStructure.kt")
public void testSealedInheritorsInComplexModuleStructure() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsInComplexModuleStructure.kt");
}
@Test
@TestMetadata("sealedInheritorsIncorrectExpect.kt")
public void testSealedInheritorsIncorrectExpect() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsIncorrectExpect.kt");
}
@Test
@TestMetadata("sealedInheritorsIncorrectNonExpect.kt")
public void testSealedInheritorsIncorrectNonExpect() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsIncorrectNonExpect.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/annotationMatching")
@TestDataPath("$PROJECT_ROOT")
@@ -26632,12 +26632,30 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/intermediateWithActualAndExpect.kt");
}
@Test
@TestMetadata("sealedInheritorsCorrectExpect.kt")
public void testSealedInheritorsCorrectExpect() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsCorrectExpect.kt");
}
@Test
@TestMetadata("sealedInheritorsInComplexModuleStructure.kt")
public void testSealedInheritorsInComplexModuleStructure() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsInComplexModuleStructure.kt");
}
@Test
@TestMetadata("sealedInheritorsIncorrectExpect.kt")
public void testSealedInheritorsIncorrectExpect() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsIncorrectExpect.kt");
}
@Test
@TestMetadata("sealedInheritorsIncorrectNonExpect.kt")
public void testSealedInheritorsIncorrectNonExpect() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsIncorrectNonExpect.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/annotationMatching")
@TestDataPath("$PROJECT_ROOT")
@@ -1791,12 +1791,30 @@ public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends Abst
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/intermediateWithActualAndExpect.kt");
}
@Test
@TestMetadata("sealedInheritorsCorrectExpect.kt")
public void testSealedInheritorsCorrectExpect() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsCorrectExpect.kt");
}
@Test
@TestMetadata("sealedInheritorsInComplexModuleStructure.kt")
public void testSealedInheritorsInComplexModuleStructure() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsInComplexModuleStructure.kt");
}
@Test
@TestMetadata("sealedInheritorsIncorrectExpect.kt")
public void testSealedInheritorsIncorrectExpect() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsIncorrectExpect.kt");
}
@Test
@TestMetadata("sealedInheritorsIncorrectNonExpect.kt")
public void testSealedInheritorsIncorrectNonExpect() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsIncorrectNonExpect.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/annotationMatching")
@TestDataPath("$PROJECT_ROOT")
@@ -1791,12 +1791,30 @@ public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFi
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/intermediateWithActualAndExpect.kt");
}
@Test
@TestMetadata("sealedInheritorsCorrectExpect.kt")
public void testSealedInheritorsCorrectExpect() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsCorrectExpect.kt");
}
@Test
@TestMetadata("sealedInheritorsInComplexModuleStructure.kt")
public void testSealedInheritorsInComplexModuleStructure() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsInComplexModuleStructure.kt");
}
@Test
@TestMetadata("sealedInheritorsIncorrectExpect.kt")
public void testSealedInheritorsIncorrectExpect() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsIncorrectExpect.kt");
}
@Test
@TestMetadata("sealedInheritorsIncorrectNonExpect.kt")
public void testSealedInheritorsIncorrectNonExpect() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsIncorrectNonExpect.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/annotationMatching")
@TestDataPath("$PROJECT_ROOT")
@@ -0,0 +1,33 @@
// FIR_IDENTICAL
// MODULE: common
// TARGET_PLATFORM: Common
package test
expect sealed class Sealed
expect class Sealed1 : Sealed
expect sealed interface SealedIface
expect class SealedImpl1 : SealedIface
// MODULE: intermediate()()(common)
// TARGET_PLATFORM: Common
package test
expect class Sealed2 : Sealed
expect class SealedImpl2 : SealedIface
// MODULE: main()()(intermediate)
// TARGET_PLATFORM: JVM
package test
actual sealed class Sealed(val v: Int)
actual class Sealed1() : Sealed(1)
actual class Sealed2() : Sealed(2)
actual sealed interface SealedIface
actual class SealedImpl1() : SealedIface
actual class SealedImpl2() : SealedIface
@@ -1,21 +0,0 @@
// MODULE: common
// TARGET_PLATFORM: Common
package foo
expect sealed class SealedWithSharedActual()
expect sealed class SealedWithPlatformActuals : SealedWithSharedActual
// MODULE: intermediate()()(common)
// TARGET_PLATFORM: Common
package foo
actual sealed class SealedWithSharedActual
class SimpleShared : <!UNRESOLVED_REFERENCE!>SealedWithPlatformActuals<!>()
// MODULE: main()()(intermediate)
// TARGET_PLATFORM: JVM
package foo
actual sealed class SealedWithPlatformActuals <!ACTUAL_WITHOUT_EXPECT!>actual constructor()<!>: <!SEALED_INHERITOR_IN_DIFFERENT_MODULE!>SealedWithSharedActual<!>()
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// MODULE: common
// TARGET_PLATFORM: Common
@@ -5,17 +6,17 @@
package foo
expect sealed class SealedWithSharedActual()
expect sealed class SealedWithPlatformActuals : SealedWithSharedActual
expect sealed class SealedWithPlatformActuals() : SealedWithSharedActual
// MODULE: intermediate()()(common)
// TARGET_PLATFORM: Common
package foo
actual sealed class SealedWithSharedActual
class SimpleShared : SealedWithPlatformActuals<!NO_CONSTRUCTOR!>()<!>
class SimpleShared : SealedWithPlatformActuals()
// MODULE: main()()(intermediate)
// TARGET_PLATFORM: JVM
package foo
actual sealed class SealedWithPlatformActuals <!ACTUAL_WITHOUT_EXPECT!>actual constructor()<!>: <!SEALED_INHERITOR_IN_DIFFERENT_MODULE!>SealedWithSharedActual<!>()
actual sealed class SealedWithPlatformActuals actual constructor(): <!SEALED_INHERITOR_IN_DIFFERENT_MODULE!>SealedWithSharedActual<!>()
@@ -4,6 +4,7 @@ package
package foo {
public sealed expect class SealedWithPlatformActuals : foo.SealedWithSharedActual {
protected constructor SealedWithPlatformActuals()
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
@@ -0,0 +1,32 @@
// FIR_IDENTICAL
// MODULE: common
// TARGET_PLATFORM: Common
package test
expect sealed class Sealed
expect class Sealed1 : Sealed
expect sealed interface SealedIface
expect class SealedImpl1 : SealedIface
// MODULE: intermediate()()(common)
// TARGET_PLATFORM: Common
package test
actual sealed class Sealed(val v: Int)
actual class Sealed1() : Sealed(1)
expect class Sealed2 : Sealed
actual sealed interface SealedIface
actual class SealedImpl1() : SealedIface
expect class SealedImpl2 : SealedIface
// MODULE: main()()(intermediate)
// TARGET_PLATFORM: JVM
package test
actual class Sealed2() : <!SEALED_INHERITOR_IN_DIFFERENT_MODULE!>Sealed<!>(2)
actual class SealedImpl2() : <!SEALED_INHERITOR_IN_DIFFERENT_MODULE!>SealedIface<!>
@@ -0,0 +1,24 @@
// FIR_IDENTICAL
// MODULE: common
// TARGET_PLATFORM: Common
package test
sealed class SealedExpectActual(val v: Int)
class SealedExpectActual1() : SealedExpectActual(1)
// MODULE: intermediate()()(common)
// TARGET_PLATFORM: Common
package test
/* sealed inheritors are allowed in dependsOn source sets only for expect delclations */
class SealedExpectActual2() : <!SEALED_INHERITOR_IN_DIFFERENT_MODULE!>SealedExpectActual<!>(2)
// MODULE: main()()(intermediate)
// TARGET_PLATFORM: JVM
package test
/* sealed inheritors are allowed in dependsOn source sets only for expect delclations */
class SealedExpectActual3() : <!SEALED_INHERITOR_IN_DIFFERENT_MODULE!>SealedExpectActual<!>(3)
@@ -26632,12 +26632,30 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/intermediateWithActualAndExpect.kt");
}
@Test
@TestMetadata("sealedInheritorsCorrectExpect.kt")
public void testSealedInheritorsCorrectExpect() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsCorrectExpect.kt");
}
@Test
@TestMetadata("sealedInheritorsInComplexModuleStructure.kt")
public void testSealedInheritorsInComplexModuleStructure() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsInComplexModuleStructure.kt");
}
@Test
@TestMetadata("sealedInheritorsIncorrectExpect.kt")
public void testSealedInheritorsIncorrectExpect() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsIncorrectExpect.kt");
}
@Test
@TestMetadata("sealedInheritorsIncorrectNonExpect.kt")
public void testSealedInheritorsIncorrectNonExpect() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/sealedInheritorsIncorrectNonExpect.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/annotationMatching")
@TestDataPath("$PROJECT_ROOT")