diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index b13e570bf6b..7eefcfa99a3 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -21228,12 +21228,6 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true); } - @Test - @TestMetadata("expectAndActualInSameModule.kt") - public void testExpectAndActualInSameModule() throws Exception { - runTest("compiler/testData/diagnostics/tests/multiplatform/expectAndActualInSameModule.kt"); - } - @Test @TestMetadata("expectDataObject.kt") public void testExpectDataObject() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index c87d4985c01..e90f86e5820 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -21234,12 +21234,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true); } - @Test - @TestMetadata("expectAndActualInSameModule.kt") - public void testExpectAndActualInSameModule() throws Exception { - runTest("compiler/testData/diagnostics/tests/multiplatform/expectAndActualInSameModule.kt"); - } - @Test @TestMetadata("expectDataObject.kt") public void testExpectDataObject() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index d0c7379b960..ef88d2e3e61 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java @@ -21228,12 +21228,6 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true); } - @Test - @TestMetadata("expectAndActualInSameModule.kt") - public void testExpectAndActualInSameModule() throws Exception { - runTest("compiler/testData/diagnostics/tests/multiplatform/expectAndActualInSameModule.kt"); - } - @Test @TestMetadata("expectDataObject.kt") public void testExpectDataObject() throws Exception { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 374a5cfdc68..25cb21b9142 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -805,8 +805,6 @@ public interface Errors { DiagnosticFactory2.create(ERROR, ACTUAL_DECLARATION_NAME); DiagnosticFactory0 ACTUAL_MISSING = DiagnosticFactory0.create(ERROR, ACTUAL_DECLARATION_NAME); - DiagnosticFactory0 EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE = DiagnosticFactory0.create(WARNING, DECLARATION_NAME); - DiagnosticFactory0 OPTIONAL_EXPECTATION_NOT_ON_EXPECTED = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 OPTIONAL_DECLARATION_OUTSIDE_OF_ANNOTATION_ENTRY = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE = 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 03379e6acc1..df65ee19ef9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -339,7 +339,6 @@ public class DefaultErrorMessages { MAP.put(NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS, "Actual class ''{0}'' has no corresponding members for expected class members:{1}", NAME, adaptGenerics2(IncompatibleExpectedActualClassScopesRenderer.TEXT)); MAP.put(ACTUAL_MISSING, "Declaration must be marked with 'actual'"); - MAP.put(EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE, "Expect and corresponding actual are declared in the same module, which will be prohibited in Kotlin 2.0. See https://youtrack.jetbrains.com/issue/KT-55177"); MAP.put(OPTIONAL_EXPECTATION_NOT_ON_EXPECTED, "'@OptionalExpectation' can only be used on an expected annotation class"); MAP.put(OPTIONAL_DECLARATION_OUTSIDE_OF_ANNOTATION_ENTRY, "Declaration annotated with '@OptionalExpectation' can only be used inside an annotation entry"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExpectedActualDeclarationChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExpectedActualDeclarationChecker.kt index b090f8f281d..012b3666f69 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExpectedActualDeclarationChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExpectedActualDeclarationChecker.kt @@ -181,46 +181,27 @@ class ExpectedActualDeclarationChecker( } // Here we have exactly one compatible actual and/or some weakly incompatible. In either case, we don't report anything on expect... - val actualMembers = actuals.filter { it.key.isCompatibleOrWeakCompatible() }.flatMap { it.value } + val actualMembers = actuals.asSequence() + .filter { it.key.isCompatibleOrWeakCompatible() }.flatMap { it.value.asSequence() } // ...except diagnostics regarding missing actual keyword, because in that case we won't start looking for the actual at all if (checkActualModifier) { actualMembers.forEach { reportMissingActualModifier(it, reportOn = null, trace) } } - reportExpectAndActualInTheSameModule(reportOn, actualMembers, trace) - expectActualTracker.reportExpectActual(expected = expectDescriptor, actualMembers = actualMembers) } private fun reportMissingActualModifier(actual: MemberDescriptor, reportOn: KtNamedDeclaration?, trace: BindingTrace) { if (actual.isActual) return @Suppress("NAME_SHADOWING") - val reportOn = reportOn ?: actual.declarationSource ?: return + val reportOn = reportOn ?: (actual.source as? KotlinSourceElement)?.psi as? KtNamedDeclaration ?: return if (requireActualModifier(actual)) { trace.report(Errors.ACTUAL_MISSING.on(reportOn)) } } - private val MemberDescriptor.declarationSource: KtNamedDeclaration? - get() = (this.source as? KotlinSourceElement)?.psi as? KtNamedDeclaration - - private fun reportExpectAndActualInTheSameModule( - expectSource: KtNamedDeclaration, - actualMembers: List, - trace: BindingTrace - ) { - if (expectSource.containingKtFile.isCommonSource == true) return - val actualMembersWithModifier = actualMembers.filter { it.isActual } - if (actualMembersWithModifier.isEmpty()) return - trace.report(Errors.EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE.on(expectSource)) - for (actual in actualMembersWithModifier) { - val actualSource = actual.declarationSource ?: continue - trace.report(Errors.EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE.on(actualSource)) - } - } - private fun MemberDescriptor.hasNoActualWithDiagnostic( compatibility: Map, List> ): Boolean { @@ -230,7 +211,7 @@ class ExpectedActualDeclarationChecker( } } - private fun ExpectActualTracker.reportExpectActual(expected: MemberDescriptor, actualMembers: List) { + private fun ExpectActualTracker.reportExpectActual(expected: MemberDescriptor, actualMembers: Sequence) { if (this is ExpectActualTracker.DoNothing) return val expectedFile = sourceFile(expected) ?: return diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/actualTypealiasToCompiledInlineClass/expectActualLv14.kt b/compiler/testData/compileKotlinAgainstCustomBinaries/actualTypealiasToCompiledInlineClass/expectActualLv14.kt index 50633ab4ccc..1584cbb7b84 100644 --- a/compiler/testData/compileKotlinAgainstCustomBinaries/actualTypealiasToCompiledInlineClass/expectActualLv14.kt +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/actualTypealiasToCompiledInlineClass/expectActualLv14.kt @@ -1,5 +1,3 @@ -@file:Suppress("EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE") - package test @Suppress("INLINE_CLASS_DEPRECATED", "EXPERIMENTAL_FEATURE_WARNING") diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/actualTypealiasToCompiledInlineClass/expectActualLv15.kt b/compiler/testData/compileKotlinAgainstCustomBinaries/actualTypealiasToCompiledInlineClass/expectActualLv15.kt index 71d80a26d81..fd0a542f705 100644 --- a/compiler/testData/compileKotlinAgainstCustomBinaries/actualTypealiasToCompiledInlineClass/expectActualLv15.kt +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/actualTypealiasToCompiledInlineClass/expectActualLv15.kt @@ -1,5 +1,3 @@ -@file:Suppress("EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE") - package test @kotlin.jvm.JvmInline diff --git a/compiler/testData/diagnostics/tests/IncDecOperatorsInExpectClass.fir.kt b/compiler/testData/diagnostics/tests/IncDecOperatorsInExpectClass.fir.kt deleted file mode 100644 index ea703db9269..00000000000 --- a/compiler/testData/diagnostics/tests/IncDecOperatorsInExpectClass.fir.kt +++ /dev/null @@ -1,10 +0,0 @@ -// !LANGUAGE: +MultiPlatformProjects -// SKIP_TXT -// Issue: KT-49714 - -expect class Counter { - operator fun inc(): Counter - operator fun dec(): Counter -} - -actual typealias Counter = Int \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/IncDecOperatorsInExpectClass.kt b/compiler/testData/diagnostics/tests/IncDecOperatorsInExpectClass.kt index c69d5072e23..cb90b5e2b99 100644 --- a/compiler/testData/diagnostics/tests/IncDecOperatorsInExpectClass.kt +++ b/compiler/testData/diagnostics/tests/IncDecOperatorsInExpectClass.kt @@ -1,10 +1,11 @@ +// FIR_IDENTICAL // !LANGUAGE: +MultiPlatformProjects // SKIP_TXT // Issue: KT-49714 -expect class Counter { +expect class Counter { operator fun inc(): Counter operator fun dec(): Counter } -actual typealias Counter = Int +actual typealias Counter = Int diff --git a/compiler/testData/diagnostics/tests/multiplatform/expectAndActualInSameModule.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/expectAndActualInSameModule.fir.kt deleted file mode 100644 index 50201b6d3e0..00000000000 --- a/compiler/testData/diagnostics/tests/multiplatform/expectAndActualInSameModule.fir.kt +++ /dev/null @@ -1,17 +0,0 @@ -// ISSUE: KT-40904, KT-55177 - -expect class Foo { - fun memberFun() - val memberProp: Int -} -actual class Foo { - actual fun memberFun() {} - actual val memberProp: Int = 10 -} - -expect fun foo() -actual fun foo() {} - -expect val x: String -actual val x: String - get() = "hello" diff --git a/compiler/testData/diagnostics/tests/multiplatform/expectAndActualInSameModule.kt b/compiler/testData/diagnostics/tests/multiplatform/expectAndActualInSameModule.kt deleted file mode 100644 index 2b9810c054a..00000000000 --- a/compiler/testData/diagnostics/tests/multiplatform/expectAndActualInSameModule.kt +++ /dev/null @@ -1,17 +0,0 @@ -// ISSUE: KT-40904, KT-55177 - -expect class Foo { - fun memberFun() - val memberProp: Int -} -actual class Foo { - actual fun memberFun() {} - actual val memberProp: Int = 10 -} - -expect fun foo() -actual fun foo() {} - -expect val x: String -actual val x: String - get() = "hello" diff --git a/compiler/testData/diagnostics/tests/multiplatform/expectAndActualInSameModule.txt b/compiler/testData/diagnostics/tests/multiplatform/expectAndActualInSameModule.txt deleted file mode 100644 index adc433e97e2..00000000000 --- a/compiler/testData/diagnostics/tests/multiplatform/expectAndActualInSameModule.txt +++ /dev/null @@ -1,14 +0,0 @@ -package - -public actual val x: kotlin.String -public actual fun foo(): kotlin.Unit - -public final actual class Foo { - public constructor Foo() - public actual final val memberProp: kotlin.Int = 10 - 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 final actual fun memberFun(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - 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 24668d51b43..d05a466970b 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 @@ -21234,12 +21234,6 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true); } - @Test - @TestMetadata("expectAndActualInSameModule.kt") - public void testExpectAndActualInSameModule() throws Exception { - runTest("compiler/testData/diagnostics/tests/multiplatform/expectAndActualInSameModule.kt"); - } - @Test @TestMetadata("expectDataObject.kt") public void testExpectDataObject() throws Exception { diff --git a/libraries/stdlib/common/test/jsCollectionFactories.kt b/libraries/stdlib/common/test/jsCollectionFactories.kt index e12aef2a8d0..47d5e8a665b 100644 --- a/libraries/stdlib/common/test/jsCollectionFactories.kt +++ b/libraries/stdlib/common/test/jsCollectionFactories.kt @@ -2,7 +2,6 @@ * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -@file:Suppress("EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE") package test.collections.js diff --git a/libraries/stdlib/common/test/testUtils.kt b/libraries/stdlib/common/test/testUtils.kt index 1ac998dda47..9b5ffaf3ee8 100644 --- a/libraries/stdlib/common/test/testUtils.kt +++ b/libraries/stdlib/common/test/testUtils.kt @@ -2,7 +2,6 @@ * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -@file:Suppress("EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE") package test @@ -34,4 +33,4 @@ public expect object BackReferenceHandling { val nonExistentGroup: HandlingOption val nonExistentNamedGroup: HandlingOption val groupZero: HandlingOption -} +} \ No newline at end of file diff --git a/libraries/stdlib/jvm/test/js/StubsJVM.kt b/libraries/stdlib/jvm/test/js/StubsJVM.kt index 36e3e7ccf09..0fd5c148140 100644 --- a/libraries/stdlib/jvm/test/js/StubsJVM.kt +++ b/libraries/stdlib/jvm/test/js/StubsJVM.kt @@ -2,7 +2,6 @@ * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -@file:Suppress("EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE") package test.collections.js diff --git a/libraries/stdlib/jvm/test/testUtilsJVM.kt b/libraries/stdlib/jvm/test/testUtilsJVM.kt index ac503baec8d..22a7d06535d 100644 --- a/libraries/stdlib/jvm/test/testUtilsJVM.kt +++ b/libraries/stdlib/jvm/test/testUtilsJVM.kt @@ -2,7 +2,6 @@ * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -@file:Suppress("EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE") package test @@ -39,4 +38,4 @@ public actual object BackReferenceHandling { actual val nonExistentGroup: HandlingOption = HandlingOption.MATCH_NOTHING actual val nonExistentNamedGroup: HandlingOption = HandlingOption.THROW actual val groupZero: HandlingOption = HandlingOption.THROW -} +} \ No newline at end of file