diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index a331bb1d17ef4..0cac895b018f9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -866,10 +866,6 @@ public interface Errors { DiagnosticFactory1> TYPE_PARAMETER_NAMES_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING = DiagnosticFactory1.create(WARNING, TYPE_PARAMETERS_OR_DECLARATION_SIGNATURE); - DiagnosticFactory3, ClassDescriptor> - ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_SUPERTYPES_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING = - DiagnosticFactory3.create(WARNING, DECLARATION_NAME); - DiagnosticFactory0 EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING = DiagnosticFactory0.create(WARNING, EXPECT_ACTUAL_MODIFIER); DiagnosticFactory0 OPTIONAL_EXPECTATION_NOT_ON_EXPECTED = DiagnosticFactory0.create(ERROR); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 82633b3a69a88..efb95d63f1110 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -437,16 +437,6 @@ public static DiagnosticRenderer getRendererForDiagnostic(@NotNull UnboundDiagno "{0}. This warning will become an error in future releases. Also see https://youtrack.jetbrains.com/issue/KT-22841 for more details", ExpectActualScopeDiffRenderer.INSTANCE); - MAP.put(ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_SUPERTYPES_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING, - "{0}: actual class and its non-final expect class must declare exactly the same supertypes. " + - "Actual class declares the following supertypes that are not presented in expect class: {1}.\n" + - "This error happens because the expect class ''{2}'' is non-final. " + - "This warning will become an error in future releases.\n" + - "Also see https://youtrack.jetbrains.com/issue/KT-22841 for more details", - CAPITALIZED_DECLARATION_NAME_WITH_KIND_AND_PLATFORM, - new ListRenderer<>(TO_STRING, (elem) -> "'" + elem + "'"), - NAME); - MAP.put(EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING, "'expect'/'actual' classes (including interfaces, objects, annotations, enums, and 'actual' typealiases) are in Beta. " + "You can use -Xexpect-actual-classes flag to suppress this warning. " + diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ActualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ActualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker.kt index 5bb267ff12d14..6f0d3c2983cf8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ActualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ActualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker.kt @@ -32,33 +32,10 @@ object ActualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker : declaration as KtClassLikeDeclaration descriptor as ClassifierDescriptorWithTypeParameters - checkSupertypes(expect, actual, context, declaration, descriptor) checkExpectActualScopeDiff(expect, actual, context, declaration, descriptor) } } -private fun checkSupertypes( - expect: ClassDescriptor, - actual: ClassDescriptor, - context: DeclarationCheckerContext, - declaration: KtClassLikeDeclaration, - descriptor: ClassifierDescriptorWithTypeParameters, -) { - val addedSupertypes = (actual.getSuperInterfaces() + listOfNotNull(actual.getSuperClassNotAny())).map(ClassDescriptor::fqNameSafe) - - (expect.getSuperInterfaces() + listOfNotNull(expect.getSuperClassNotAny())).map(ClassDescriptor::fqNameSafe).toSet() - - if (addedSupertypes.isNotEmpty()) { - context.trace.report( - Errors.ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_SUPERTYPES_AS_NON_FINAL_EXPECT_CLASSIFIER_WARNING.on( - declaration, - descriptor, - addedSupertypes.map(FqName::shortName), - expect, - ) - ) - } -} - private fun checkExpectActualScopeDiff( expect: ClassDescriptor, actual: ClassDescriptor, diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectEmptySuperClass.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectEmptySuperClass.fir.kt deleted file mode 100644 index 269e85b29d38a..0000000000000 --- a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectEmptySuperClass.fir.kt +++ /dev/null @@ -1,17 +0,0 @@ -// MODULE: m1-common -// FILE: common.kt - -expect open class Foo { - fun existingMethod() - val existingParam: Int -} - -// MODULE: m2-jvm()()(m1-common) -// FILE: jvm.kt - -open class InjectedEmptySuperClass() - -actual open class Foo : InjectedEmptySuperClass() { - actual fun existingMethod() {} - actual val existingParam: Int = 904 -} diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectEmptySuperClass.kt b/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectEmptySuperClass.kt index 77963d07947ba..e09c8ef40a4e2 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectEmptySuperClass.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectEmptySuperClass.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // MODULE: m1-common // FILE: common.kt @@ -11,7 +12,7 @@ expect open class Foo { open class InjectedEmptySuperClass() -actual open class Foo : InjectedEmptySuperClass() { +actual open class Foo : InjectedEmptySuperClass() { actual fun existingMethod() {} actual val existingParam: Int = 904 } diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectPublicFakeOverrideMethod.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectPublicFakeOverrideMethod.fir.kt deleted file mode 100644 index 21ef0d8b3c578..0000000000000 --- a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectPublicFakeOverrideMethod.fir.kt +++ /dev/null @@ -1,19 +0,0 @@ -// MODULE: m1-common -// FILE: common.kt - -expect open class Foo { - fun existingMethod() - val existingParam: Int -} - -// MODULE: m2-jvm()()(m1-common) -// FILE: jvm.kt - -open class Injector { - fun injectedMethod() {} -} - -actual open class Foo : Injector() { - actual fun existingMethod() {} - actual val existingParam: Int = 904 -} diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectPublicFakeOverrideMethod.kt b/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectPublicFakeOverrideMethod.kt index b6fb41a12d0d5..4825aaee585e9 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectPublicFakeOverrideMethod.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectPublicFakeOverrideMethod.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // MODULE: m1-common // FILE: common.kt @@ -13,7 +14,7 @@ open class Injector { fun injectedMethod() {} } -actual open class Foo : Injector() { +actual open class Foo : Injector() { actual fun existingMethod() {} actual val existingParam: Int = 904 } diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectSupertype_SupertypeIsExpectActualPair.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectSupertype_SupertypeIsExpectActualPair.fir.kt deleted file mode 100644 index 28aed272a3323..0000000000000 --- a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectSupertype_SupertypeIsExpectActualPair.fir.kt +++ /dev/null @@ -1,24 +0,0 @@ -// WITH_STDLIB -// MODULE: m1-common -// FILE: common.kt - -expect open class Base { - fun injected() -} - -expect open class Foo { - fun existingMethod() - val existingParam: Int -} - -// MODULE: m2-jvm()()(m1-common) -// FILE: jvm.kt - -actual open class Base { - actual fun injected() {} -} - -actual open class Foo : Base() { - actual fun existingMethod() {} - actual val existingParam: Int = 904 -} diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectSupertype_SupertypeIsExpectActualPair.kt b/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectSupertype_SupertypeIsExpectActualPair.kt index f905b7b52dc6b..42f5815ede851 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectSupertype_SupertypeIsExpectActualPair.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectSupertype_SupertypeIsExpectActualPair.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // WITH_STDLIB // MODULE: m1-common // FILE: common.kt @@ -18,7 +19,7 @@ actual open class Base { actual fun injected() {} } -actual open class Foo : Base() { +actual open class Foo : Base() { actual fun existingMethod() {} actual val existingParam: Int = 904 } diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectSupertype_SupertypeIsExpectActualPair_transitiveFakeOverride.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectSupertype_SupertypeIsExpectActualPair_transitiveFakeOverride.fir.kt deleted file mode 100644 index f0d4ccecf045a..0000000000000 --- a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectSupertype_SupertypeIsExpectActualPair_transitiveFakeOverride.fir.kt +++ /dev/null @@ -1,26 +0,0 @@ -// WITH_STDLIB -// MODULE: m1-common -// FILE: common.kt - -expect open class Base { - fun injected() -} - -expect open class Foo { - fun existingMethod() - val existingParam: Int -} - -// MODULE: m2-jvm()()(m1-common) -// FILE: jvm.kt - -actual open class Base { - actual fun injected() {} -} - -open class Transitive : Base() - -actual open class Foo : Transitive() { - actual fun existingMethod() {} - actual val existingParam: Int = 904 -} diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectSupertype_SupertypeIsExpectActualPair_transitiveFakeOverride.kt b/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectSupertype_SupertypeIsExpectActualPair_transitiveFakeOverride.kt index 8582f0f97afea..5a2ab96dbd7f7 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectSupertype_SupertypeIsExpectActualPair_transitiveFakeOverride.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectSupertype_SupertypeIsExpectActualPair_transitiveFakeOverride.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // WITH_STDLIB // MODULE: m1-common // FILE: common.kt @@ -20,7 +21,7 @@ actual open class Base { open class Transitive : Base() -actual open class Foo : Transitive() { +actual open class Foo : Transitive() { actual fun existingMethod() {} actual val existingParam: Int = 904 } diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/supertypeIsExpectActual_injectSupertype.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/supertypeIsExpectActual_injectSupertype.fir.kt deleted file mode 100644 index 66b8ca422a2b0..0000000000000 --- a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/supertypeIsExpectActual_injectSupertype.fir.kt +++ /dev/null @@ -1,24 +0,0 @@ -// WITH_STDLIB -// MODULE: m1-common -// FILE: common.kt - -expect open class Base { - fun injected() -} - -expect open class Foo { - fun existingMethod() - val existingParam: Int -} - -// MODULE: m2-jvm()()(m1-common) -// FILE: jvm.kt - -actual open class Base { - actual fun injected() {} -} - -actual open class Foo : Base() { - actual fun existingMethod() {} - actual val existingParam: Int = 904 -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/supertypeIsExpectActual_injectSupertype.kt b/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/supertypeIsExpectActual_injectSupertype.kt index f905b7b52dc6b..42f5815ede851 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/supertypeIsExpectActual_injectSupertype.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/supertypeIsExpectActual_injectSupertype.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // WITH_STDLIB // MODULE: m1-common // FILE: common.kt @@ -18,7 +19,7 @@ actual open class Base { actual fun injected() {} } -actual open class Foo : Base() { +actual open class Foo : Base() { actual fun existingMethod() {} actual val existingParam: Int = 904 } diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/supertypeIsExpectActual_injectSupertype_transitiveSubstitutionFakeOverride.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/supertypeIsExpectActual_injectSupertype_transitiveSubstitutionFakeOverride.fir.kt deleted file mode 100644 index 608cee313cf2e..0000000000000 --- a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/supertypeIsExpectActual_injectSupertype_transitiveSubstitutionFakeOverride.fir.kt +++ /dev/null @@ -1,26 +0,0 @@ -// WITH_STDLIB -// MODULE: m1-common -// FILE: common.kt - -expect open class Base { - fun injected(param: T) -} - -expect open class Foo { - fun existingMethod() - val existingParam: Int -} - -// MODULE: m2-jvm()()(m1-common) -// FILE: jvm.kt - -actual open class Base { - actual fun injected(param: T) {} -} - -open class Transitive : Base() - -actual open class Foo : Transitive() { - actual fun existingMethod() {} - actual val existingParam: Int = 904 -} diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/supertypeIsExpectActual_injectSupertype_transitiveSubstitutionFakeOverride.kt b/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/supertypeIsExpectActual_injectSupertype_transitiveSubstitutionFakeOverride.kt index 2dec1a8fa5f3c..8c26755929130 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/supertypeIsExpectActual_injectSupertype_transitiveSubstitutionFakeOverride.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/supertypeIsExpectActual_injectSupertype_transitiveSubstitutionFakeOverride.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // WITH_STDLIB // MODULE: m1-common // FILE: common.kt @@ -20,7 +21,7 @@ actual open class Base { open class Transitive : Base() -actual open class Foo : Transitive() { +actual open class Foo : Transitive() { actual fun existingMethod() {} actual val existingParam: Int = 904 } diff --git a/compiler/testData/diagnostics/tests/multiplatform/headerClass/genericClassImplTypeAlias.kt b/compiler/testData/diagnostics/tests/multiplatform/headerClass/genericClassImplTypeAlias.kt index 4f33c2ad2a350..03130c8e8a3e6 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/headerClass/genericClassImplTypeAlias.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/headerClass/genericClassImplTypeAlias.kt @@ -22,16 +22,16 @@ class B actual typealias C1 = String actual typealias C2 = List actual typealias C3 = List -actual typealias C4 = MutableMap -actual typealias C5 = MutableMap +actual typealias C4 = MutableMap +actual typealias C5 = MutableMap actual typealias C51 = MutableMap actual typealias C52 = MutableMap actual typealias C53 = A> actual typealias C54 = B> -actual typealias C6 = MutableList -actual typealias C7 = MutableList -actual typealias C8 = MutableList<*> -actual typealias C9 = MutableList +actual typealias C6 = MutableList +actual typealias C7 = MutableList +actual typealias C8 = MutableList<*> +actual typealias C9 = MutableList typealias Tmp = MutableList -actual typealias C10 = Tmp +actual typealias C10 = Tmp diff --git a/compiler/testData/diagnostics/tests/multiplatform/implDelegatedMember.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/implDelegatedMember.fir.kt deleted file mode 100644 index 09210b9f41c42..0000000000000 --- a/compiler/testData/diagnostics/tests/multiplatform/implDelegatedMember.fir.kt +++ /dev/null @@ -1,18 +0,0 @@ -// MODULE: m1-common -// FILE: common.kt - -expect open class Foo { - open fun bar(): String -} - -// MODULE: m2-jvm()()(m1-common) -// FILE: jvm.kt - -interface Bar { - fun bar(): String -} - -val bar: Bar - get() = null!! - -actual open class Foo : Bar by bar diff --git a/compiler/testData/diagnostics/tests/multiplatform/implDelegatedMember.kt b/compiler/testData/diagnostics/tests/multiplatform/implDelegatedMember.kt index 6f785462a2513..0681dd8ba6a87 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/implDelegatedMember.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/implDelegatedMember.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // MODULE: m1-common // FILE: common.kt @@ -15,4 +16,4 @@ interface Bar { val bar: Bar get() = null!! -actual open class Foo : Bar by bar +actual open class Foo : Bar by bar diff --git a/compiler/testData/diagnostics/tests/multiplatform/implicitActualFakeOverride_AbstractMap.kt b/compiler/testData/diagnostics/tests/multiplatform/implicitActualFakeOverride_AbstractMap.kt index 472ae1e4cb70b..b2c3ad70bd914 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/implicitActualFakeOverride_AbstractMap.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/implicitActualFakeOverride_AbstractMap.kt @@ -12,4 +12,4 @@ public expect abstract class AbstractMutableMap : MutableMap { import java.util.AbstractMap -public actual abstract class AbstractMutableMap() : MutableMap, AbstractMap() +public actual abstract class AbstractMutableMap() : MutableMap, AbstractMap()