[Test] Add more diagnostic tests for cases with expect class in supertypes

Related issues: KT-58845, KT-58881, KT-64187
This commit is contained in:
Dmitriy Novozhilov
2024-01-09 16:59:09 +02:00
committed by Nikolay Lunyak
parent ed04cca62b
commit 77547c0312
13 changed files with 304 additions and 18 deletions
@@ -26586,6 +26586,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/scopes")
@TestDataPath("$PROJECT_ROOT")
public class Scopes {
@Test
@TestMetadata("actualAbstractClassWithAdditionalMembers.kt")
public void testActualAbstractClassWithAdditionalMembers() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/actualAbstractClassWithAdditionalMembers.kt");
}
@Test
@TestMetadata("actualFakeOverride.kt")
public void testActualFakeOverride() throws Exception {
@@ -26675,11 +26681,29 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/manyInterfacesMemberNotImplemented.kt");
}
@Test
@TestMetadata("mixedFunctionalTypesInSupertypes.kt")
public void testMixedFunctionalTypesInSupertypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/mixedFunctionalTypesInSupertypes.kt");
}
@Test
@TestMetadata("multipleDefaultsInhereted.kt")
public void testMultipleDefaultsInhereted() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/multipleDefaultsInhereted.kt");
}
@Test
@TestMetadata("multipleExpectInterfacesImplementation.kt")
public void testMultipleExpectInterfacesImplementation() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/multipleExpectInterfacesImplementation.kt");
}
@Test
@TestMetadata("scopeOfFunInterface.kt")
public void testScopeOfFunInterface() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/scopeOfFunInterface.kt");
}
}
@Nested
@@ -26586,6 +26586,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/scopes")
@TestDataPath("$PROJECT_ROOT")
public class Scopes {
@Test
@TestMetadata("actualAbstractClassWithAdditionalMembers.kt")
public void testActualAbstractClassWithAdditionalMembers() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/actualAbstractClassWithAdditionalMembers.kt");
}
@Test
@TestMetadata("actualFakeOverride.kt")
public void testActualFakeOverride() throws Exception {
@@ -26675,11 +26681,29 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/manyInterfacesMemberNotImplemented.kt");
}
@Test
@TestMetadata("mixedFunctionalTypesInSupertypes.kt")
public void testMixedFunctionalTypesInSupertypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/mixedFunctionalTypesInSupertypes.kt");
}
@Test
@TestMetadata("multipleDefaultsInhereted.kt")
public void testMultipleDefaultsInhereted() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/multipleDefaultsInhereted.kt");
}
@Test
@TestMetadata("multipleExpectInterfacesImplementation.kt")
public void testMultipleExpectInterfacesImplementation() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/multipleExpectInterfacesImplementation.kt");
}
@Test
@TestMetadata("scopeOfFunInterface.kt")
public void testScopeOfFunInterface() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/scopeOfFunInterface.kt");
}
}
@Nested
@@ -1935,6 +1935,12 @@ public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends Abst
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/scopes")
@TestDataPath("$PROJECT_ROOT")
public class Scopes {
@Test
@TestMetadata("actualAbstractClassWithAdditionalMembers.kt")
public void testActualAbstractClassWithAdditionalMembers() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/actualAbstractClassWithAdditionalMembers.kt");
}
@Test
@TestMetadata("actualFakeOverride.kt")
public void testActualFakeOverride() throws Exception {
@@ -2024,11 +2030,29 @@ public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends Abst
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/manyInterfacesMemberNotImplemented.kt");
}
@Test
@TestMetadata("mixedFunctionalTypesInSupertypes.kt")
public void testMixedFunctionalTypesInSupertypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/mixedFunctionalTypesInSupertypes.kt");
}
@Test
@TestMetadata("multipleDefaultsInhereted.kt")
public void testMultipleDefaultsInhereted() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/multipleDefaultsInhereted.kt");
}
@Test
@TestMetadata("multipleExpectInterfacesImplementation.kt")
public void testMultipleExpectInterfacesImplementation() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/multipleExpectInterfacesImplementation.kt");
}
@Test
@TestMetadata("scopeOfFunInterface.kt")
public void testScopeOfFunInterface() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/scopeOfFunInterface.kt");
}
}
@Nested
@@ -1935,6 +1935,12 @@ public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFi
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/scopes")
@TestDataPath("$PROJECT_ROOT")
public class Scopes {
@Test
@TestMetadata("actualAbstractClassWithAdditionalMembers.kt")
public void testActualAbstractClassWithAdditionalMembers() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/actualAbstractClassWithAdditionalMembers.kt");
}
@Test
@TestMetadata("actualFakeOverride.kt")
public void testActualFakeOverride() throws Exception {
@@ -2024,11 +2030,29 @@ public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFi
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/manyInterfacesMemberNotImplemented.kt");
}
@Test
@TestMetadata("mixedFunctionalTypesInSupertypes.kt")
public void testMixedFunctionalTypesInSupertypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/mixedFunctionalTypesInSupertypes.kt");
}
@Test
@TestMetadata("multipleDefaultsInhereted.kt")
public void testMultipleDefaultsInhereted() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/multipleDefaultsInhereted.kt");
}
@Test
@TestMetadata("multipleExpectInterfacesImplementation.kt")
public void testMultipleExpectInterfacesImplementation() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/multipleExpectInterfacesImplementation.kt");
}
@Test
@TestMetadata("scopeOfFunInterface.kt")
public void testScopeOfFunInterface() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/scopeOfFunInterface.kt");
}
}
@Nested
@@ -0,0 +1,23 @@
// FIR_IDENTICAL
// TARGET_BACKEND: JVM
// LANGUAGE: +MultiPlatformProjects
// ISSUE: KT-64187
// MODULE: common
// TARGET_PLATFORM: Common
// FILE: common.kt
expect abstract class Base
expect class Derived : Base
// MODULE: jvm()()(common)
// TARGET_PLATFORM: JVM
// FILE: main.kt
actual abstract class Base {
abstract fun foo()
}
actual class Derived : Base() {
override fun foo() {}
}
@@ -1,24 +1,29 @@
// TARGET_BACKEND: JVM
// !LANGUAGE: +MultiPlatformProjects
// LANGUAGE: +MultiPlatformProjects
// MODULE: common
// TARGET_PLATFORM: Common
// MODULE: m1-common
// FILE: common.kt
expect open class C1()
expect interface I1
open class A : C1(), I1
open class B : I1, C1()
open class Common1_1 : C1(), I1
open class Common1_2 : I1, C1()
expect open class Expect1_1 : C1, I1
expect open class Expect1_2 : I1, C1
expect abstract class C2()
expect interface I2
// TODO: KT-58829
class C : C2(), I2
open class Common2_1 : C2(), I2
open class Common2_2 : I2, C2()
// MODULE: jvm()()(common)
// TARGET_PLATFORM: JVM
expect open class Expect2_1 : C2, I2
expect open class Expect2_2 : I2, C2
// MODULE: m1-jvm()()(m1-common)
// FILE: main.kt
actual open class C1 {
@@ -29,6 +34,10 @@ actual interface I1 {
fun f() {}
}
actual open <!MANY_IMPL_MEMBER_NOT_IMPLEMENTED!>class Expect1_1<!> : C1(), I1
actual open <!MANY_IMPL_MEMBER_NOT_IMPLEMENTED!>class Expect1_2<!> : I1, C1()
actual abstract class C2 actual constructor() {
fun g() {}
}
@@ -36,3 +45,6 @@ actual abstract class C2 actual constructor() {
actual interface I2 {
fun g()
}
actual open class Expect2_1 : C2(), I2
actual open class Expect2_2 : I2, C2()
@@ -1,24 +1,29 @@
// TARGET_BACKEND: JVM
// !LANGUAGE: +MultiPlatformProjects
// LANGUAGE: +MultiPlatformProjects
// MODULE: common
// TARGET_PLATFORM: Common
// MODULE: m1-common
// FILE: common.kt
expect open class C1()
expect interface I1
open <!MANY_IMPL_MEMBER_NOT_IMPLEMENTED{JVM}!>class A<!> : C1(), I1
open <!MANY_IMPL_MEMBER_NOT_IMPLEMENTED{JVM}!>class B<!> : I1, C1()
open <!MANY_IMPL_MEMBER_NOT_IMPLEMENTED{JVM}!>class Common1_1<!> : C1(), I1
open <!MANY_IMPL_MEMBER_NOT_IMPLEMENTED{JVM}!>class Common1_2<!> : I1, C1()
expect open <!MANY_IMPL_MEMBER_NOT_IMPLEMENTED{JVM}!>class Expect1_1<!> : C1, I1
expect open <!MANY_IMPL_MEMBER_NOT_IMPLEMENTED{JVM}!>class Expect1_2<!> : I1, C1
expect abstract class C2()
expect interface I2
// TODO: KT-58829
class C : C2(), I2
open class Common2_1 : C2(), I2
open class Common2_2 : I2, C2()
// MODULE: jvm()()(common)
// TARGET_PLATFORM: JVM
expect open class Expect2_1 : C2, I2
expect open class Expect2_2 : I2, C2
// MODULE: m1-jvm()()(m1-common)
// FILE: main.kt
actual open class C1 {
@@ -29,6 +34,10 @@ actual interface I1 {
fun f() {}
}
actual open <!MANY_IMPL_MEMBER_NOT_IMPLEMENTED!>class Expect1_1<!> : C1(), I1
actual open <!MANY_IMPL_MEMBER_NOT_IMPLEMENTED!>class Expect1_2<!> : I1, C1()
actual abstract class C2 actual constructor() {
fun g() {}
}
@@ -36,3 +45,6 @@ actual abstract class C2 actual constructor() {
actual interface I2 {
fun g()
}
actual open class Expect2_1 : C2(), I2
actual open class Expect2_2 : I2, C2()
@@ -0,0 +1,23 @@
// LANGUAGE: +MultiPlatformProjects
// MODULE: common
// FILE: common.kt
expect interface I1<out R> {
fun invoke(): R
}
expect interface I2<out R> {
suspend fun invoke(): R
}
<!EXPECT_ACTUAL_INCOMPATIBILITY{JVM}, EXPECT_ACTUAL_INCOMPATIBILITY{JVM}!>expect interface ExpectInterface : I1<Int>, I2<Int><!>
interface CommonInterface : I1<Int>, I2<Int>
// MODULE: jvm()()(common)
// FILE: main.kt
<!ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE!>actual typealias I1<R> = () -> R<!>
<!ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE!>actual typealias I2<R> = suspend () -> R<!>
actual interface <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>ExpectInterface<!> : <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>I1<Int>, I2<Int><!>
@@ -0,0 +1,23 @@
// LANGUAGE: +MultiPlatformProjects
// MODULE: common
// FILE: common.kt
expect interface <!NO_ACTUAL_FOR_EXPECT!>I1<!><out R> {
fun invoke(): R
}
expect interface <!NO_ACTUAL_FOR_EXPECT!>I2<!><out R> {
suspend fun invoke(): R
}
<!CONFLICTING_INHERITED_MEMBERS, CONFLICTING_INHERITED_MEMBERS{JVM}!>expect interface <!NO_ACTUAL_FOR_EXPECT!>ExpectInterface<!><!> : <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES{JVM}!>I1<Int>, I2<Int><!>
<!CONFLICTING_INHERITED_MEMBERS, CONFLICTING_INHERITED_MEMBERS{JVM}!>interface CommonInterface<!> : <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES{JVM}!>I1<Int>, I2<Int><!>
// MODULE: jvm()()(common)
// FILE: main.kt
<!ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE!>actual typealias I1<R> = () -> R<!>
<!ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE!>actual typealias I2<R> = suspend () -> R<!>
<!CONFLICTING_INHERITED_MEMBERS!>actual interface ExpectInterface<!> : <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>I1<Int>, I2<Int><!>
@@ -0,0 +1,39 @@
// FIR_IDENTICAL
// LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect interface I1 {
fun foo(x: Int = 1)
fun bar(x: Int = 1)
}
expect interface I2 {
fun foo(x: Int = 2)
fun bar(x: Int = 2)
}
<!MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES_WHEN_NO_EXPLICIT_OVERRIDE!>expect interface ExpectInterface<!> : I1, I2 {
override fun foo(<!MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES!>x: Int<!>)
}
<!MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES_WHEN_NO_EXPLICIT_OVERRIDE!>interface CommonInterface<!> : I1, I2 {
override fun foo(<!MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES!>x: Int<!>)
}
// MODULE: m1-jvm()()(m1-common)
// FILE: main.kt
actual interface I1 {
actual fun foo(x: Int)
actual fun bar(x: Int)
}
actual interface I2 {
actual fun foo(x: Int)
actual fun bar(x: Int)
}
actual interface ExpectInterface : I1, I2 {
actual override fun foo(x: Int)
}
@@ -0,0 +1,17 @@
// LANGUAGE: +MultiPlatformProjects
// ISSUE: KT-58845
// MODULE: common
// FILE: common.kt
expect interface I
fun interface F : I {
fun foo()
}
// MODULE: jvm()()(common)
// FILE: main.kt
actual interface I {
fun bar()
}
@@ -0,0 +1,17 @@
// LANGUAGE: +MultiPlatformProjects
// ISSUE: KT-58845
// MODULE: common
// FILE: common.kt
expect interface <!NO_ACTUAL_FOR_EXPECT!>I<!>
<!FUN_INTERFACE_WRONG_COUNT_OF_ABSTRACT_MEMBERS{JVM}!>fun<!> interface F : I {
fun foo()
}
// MODULE: jvm()()(common)
// FILE: main.kt
actual interface I {
fun bar()
}
@@ -26586,6 +26586,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/scopes")
@TestDataPath("$PROJECT_ROOT")
public class Scopes {
@Test
@TestMetadata("actualAbstractClassWithAdditionalMembers.kt")
public void testActualAbstractClassWithAdditionalMembers() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/actualAbstractClassWithAdditionalMembers.kt");
}
@Test
@TestMetadata("actualFakeOverride.kt")
public void testActualFakeOverride() throws Exception {
@@ -26675,11 +26681,29 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/manyInterfacesMemberNotImplemented.kt");
}
@Test
@TestMetadata("mixedFunctionalTypesInSupertypes.kt")
public void testMixedFunctionalTypesInSupertypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/mixedFunctionalTypesInSupertypes.kt");
}
@Test
@TestMetadata("multipleDefaultsInhereted.kt")
public void testMultipleDefaultsInhereted() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/multipleDefaultsInhereted.kt");
}
@Test
@TestMetadata("multipleExpectInterfacesImplementation.kt")
public void testMultipleExpectInterfacesImplementation() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/multipleExpectInterfacesImplementation.kt");
}
@Test
@TestMetadata("scopeOfFunInterface.kt")
public void testScopeOfFunInterface() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/scopes/scopeOfFunInterface.kt");
}
}
@Nested