From a3ae7868b01acd190445156ae7826d096f152ae4 Mon Sep 17 00:00:00 2001 From: Roman Efremov Date: Tue, 15 Aug 2023 10:49:01 +0200 Subject: [PATCH] [Kotlin] Don't suggest "Copy annotation to actual" fix for f/o and typealias Don't suggest quick-fix "Copy annotation from expect to actual" for fake overrides and `actual typealias`, even if the source is available. This is detected by full fqName of method or class. If it is the same as the name of `expect` declaration, we are sure that actual declaration is inside `actual class`. ^KTIJ-26633 GitOrigin-RevId: 21f2b7cb007f539b3275989e86d0ac5a04bb98b4 --- ...tualAnnotationsNotMatchExpectFixFactory.kt | 2 ++ ...LevelQuickFixMultiModuleTestGenerated.java | 25 +++++++++++++ ...notationsNotMatchExpectFixFactoryCommon.kt | 35 +++++++++++++++++++ ...tualAnnotationsNotMatchExpectFixFactory.kt | 5 ++- .../QuickFixMultiModuleTestGenerated.java | 25 +++++++++++++ .../common/common.kt | 11 ++++++ .../dependencies.txt | 4 +++ .../jvm/jvm.kt | 6 ++++ .../common/common.kt | 5 +++ .../dependencies.txt | 4 +++ .../jvm/jvm.kt | 8 +++++ .../common/common.kt | 11 ++++++ .../common/common.kt.after | 10 ++++++ .../dependencies.txt | 7 ++++ .../jvm/jvm.kt | 5 +++ .../common/common.kt | 5 +++ .../common/common.kt.after | 4 +++ .../dependencies.txt | 6 ++++ .../jvm/jvm.kt | 5 +++ .../common/common.kt | 5 +++ .../common/common.kt.after | 4 +++ .../dependencies.txt | 4 +++ .../jvm/jvm.kt | 7 ++++ 23 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualFakeOverride/common/common.kt create mode 100644 plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualFakeOverride/dependencies.txt create mode 100644 plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualFakeOverride/jvm/jvm.kt create mode 100644 plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualTypealias/common/common.kt create mode 100644 plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualTypealias/dependencies.txt create mode 100644 plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualTypealias/jvm/jvm.kt create mode 100644 plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualFakeOverride/common/common.kt create mode 100644 plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualFakeOverride/common/common.kt.after create mode 100644 plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualFakeOverride/dependencies.txt create mode 100644 plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualFakeOverride/jvm/jvm.kt create mode 100644 plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualHasNoSource/common/common.kt create mode 100644 plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualHasNoSource/common/common.kt.after create mode 100644 plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualHasNoSource/dependencies.txt create mode 100644 plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualHasNoSource/jvm/jvm.kt create mode 100644 plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualTypealias/common/common.kt create mode 100644 plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualTypealias/common/common.kt.after create mode 100644 plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualTypealias/dependencies.txt create mode 100644 plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualTypealias/jvm/jvm.kt diff --git a/plugins/kotlin/fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/ActualAnnotationsNotMatchExpectFixFactory.kt b/plugins/kotlin/fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/ActualAnnotationsNotMatchExpectFixFactory.kt index bc10379572fe..7f6aa5f22071 100644 --- a/plugins/kotlin/fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/ActualAnnotationsNotMatchExpectFixFactory.kt +++ b/plugins/kotlin/fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/ActualAnnotationsNotMatchExpectFixFactory.kt @@ -32,11 +32,13 @@ internal object ActualAnnotationsNotMatchExpectFixFactory { diagnostic: KtFirDiagnostic.ActualAnnotationsNotMatchExpect, expectAnnotationEntry: KtAnnotationEntry, ): List> { + val expectDeclaration = diagnostic.expectSymbol.psi as? KtNamedDeclaration ?: return emptyList() val actualDeclaration = diagnostic.actualSymbol.psi as? KtNamedDeclaration ?: return emptyList() val mappedIncompatibilityType = diagnostic.incompatibilityType.mapAnnotationType { it.psi as? KtAnnotationEntry } return ActualAnnotationsNotMatchExpectFixFactoryCommon.createCopyAndReplaceAnnotationFixes( + expectDeclaration, actualDeclaration, expectAnnotationEntry, mappedIncompatibilityType, diff --git a/plugins/kotlin/fir/test/org/jetbrains/kotlin/idea/fir/quickfix/HighLevelQuickFixMultiModuleTestGenerated.java b/plugins/kotlin/fir/test/org/jetbrains/kotlin/idea/fir/quickfix/HighLevelQuickFixMultiModuleTestGenerated.java index 4d2dbdd8a55c..9be627d9562b 100644 --- a/plugins/kotlin/fir/test/org/jetbrains/kotlin/idea/fir/quickfix/HighLevelQuickFixMultiModuleTestGenerated.java +++ b/plugins/kotlin/fir/test/org/jetbrains/kotlin/idea/fir/quickfix/HighLevelQuickFixMultiModuleTestGenerated.java @@ -124,6 +124,16 @@ public abstract class HighLevelQuickFixMultiModuleTestGenerated extends Abstract KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); } + @TestMetadata("copyNotSuggestedWhenActualFakeOverride") + public void testCopyNotSuggestedWhenActualFakeOverride() throws Exception { + runTest("../idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualFakeOverride/"); + } + + @TestMetadata("copyNotSuggestedWhenActualTypealias") + public void testCopyNotSuggestedWhenActualTypealias() throws Exception { + runTest("../idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualTypealias/"); + } + @TestMetadata("copyToActualConstExpression") public void testCopyToActualConstExpression() throws Exception { runTest("../idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyToActualConstExpression/"); @@ -159,6 +169,21 @@ public abstract class HighLevelQuickFixMultiModuleTestGenerated extends Abstract runTest("../idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpect/"); } + @TestMetadata("removeFromExpectSuggestedWhenActualFakeOverride") + public void testRemoveFromExpectSuggestedWhenActualFakeOverride() throws Exception { + runTest("../idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualFakeOverride/"); + } + + @TestMetadata("removeFromExpectSuggestedWhenActualHasNoSource") + public void testRemoveFromExpectSuggestedWhenActualHasNoSource() throws Exception { + runTest("../idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualHasNoSource/"); + } + + @TestMetadata("removeFromExpectSuggestedWhenActualTypealias") + public void testRemoveFromExpectSuggestedWhenActualTypealias() throws Exception { + runTest("../idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualTypealias/"); + } + @TestMetadata("replaceArgsOnActual") public void testReplaceArgsOnActual() throws Exception { runTest("../idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/replaceArgsOnActual/"); diff --git a/plugins/kotlin/frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/ActualAnnotationsNotMatchExpectFixFactoryCommon.kt b/plugins/kotlin/frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/ActualAnnotationsNotMatchExpectFixFactoryCommon.kt index b51744298d5a..d2bc20f4b166 100644 --- a/plugins/kotlin/frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/ActualAnnotationsNotMatchExpectFixFactoryCommon.kt +++ b/plugins/kotlin/frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/ActualAnnotationsNotMatchExpectFixFactoryCommon.kt @@ -1,12 +1,16 @@ // Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.idea.quickfix +import org.jetbrains.kotlin.idea.base.psi.callableIdIfNotLocal +import org.jetbrains.kotlin.idea.base.psi.classIdIfNonLocal import org.jetbrains.kotlin.idea.base.resources.KotlinBundle import org.jetbrains.kotlin.idea.codeinsight.api.classic.quickfixes.KotlinQuickFixAction import org.jetbrains.kotlin.idea.codeinsight.api.classic.quickfixes.QuickFixActionBase import org.jetbrains.kotlin.idea.inspections.RemoveAnnotationFix import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.psi.KtAnnotationEntry +import org.jetbrains.kotlin.psi.KtCallableDeclaration +import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtNamedDeclaration import org.jetbrains.kotlin.resolve.multiplatform.ExpectActualAnnotationsIncompatibilityType @@ -20,11 +24,16 @@ object ActualAnnotationsNotMatchExpectFixFactoryCommon { } fun createCopyAndReplaceAnnotationFixes( + expectDeclaration: KtNamedDeclaration, actualDeclaration: KtNamedDeclaration, expectAnnotationEntry: KtAnnotationEntry, incompatibilityType: ExpectActualAnnotationsIncompatibilityType, annotationClassIdProvider: () -> ClassId?, ): List> { + if (skipFakeOverrideAndTypealias(expectDeclaration, actualDeclaration)) { + return emptyList() + } + val actualAnnotationEntry = when (incompatibilityType) { is ExpectActualAnnotationsIncompatibilityType.MissingOnActual -> null is ExpectActualAnnotationsIncompatibilityType.DifferentOnActual -> incompatibilityType.actualAnnotation @@ -55,4 +64,30 @@ object ActualAnnotationsNotMatchExpectFixFactoryCommon { annotationClassId, ) } + + /** + * When actual is typealias, quick fix changes code somewhere in another declaration (nor expect, nor actual), which might be + * unrelated to the KMP world. + * Such a modification is incomprehensible and undesirable for the user. + * Same with actual fake overrides: user wants to fix the incompatibility between expected and actual classes, + * but quick fix changes some third class that probably serves some other purpose than just being a common parent. + */ + private fun skipFakeOverrideAndTypealias(expectDeclaration: KtNamedDeclaration, actualDeclaration: KtNamedDeclaration): Boolean { + fun notEqual(a: Any?, b: Any?): Boolean { + check(a != null && b != null) { "expect and actual cannot be local, so must always have non-null ClassId"} + return a != b + } + + return when { + expectDeclaration is KtClassOrObject && actualDeclaration is KtClassOrObject -> { + notEqual(expectDeclaration.classIdIfNonLocal, actualDeclaration.classIdIfNonLocal) + } + + expectDeclaration is KtCallableDeclaration && actualDeclaration is KtCallableDeclaration -> { + notEqual(expectDeclaration.callableIdIfNotLocal, actualDeclaration.callableIdIfNotLocal) + } + + else -> error("Unexpected types: $expectDeclaration $actualDeclaration") + } + } } diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/expectactual/ActualAnnotationsNotMatchExpectFixFactory.kt b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/expectactual/ActualAnnotationsNotMatchExpectFixFactory.kt index d566420ed289..33f75710cbc3 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/expectactual/ActualAnnotationsNotMatchExpectFixFactory.kt +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/expectactual/ActualAnnotationsNotMatchExpectFixFactory.kt @@ -32,20 +32,23 @@ internal object ActualAnnotationsNotMatchExpectFixFactory : KotlinIntentionActio ActualAnnotationsNotMatchExpectFixFactoryCommon.createRemoveAnnotationFromExpectFix(expectAnnotationEntry) return listOfNotNull(removeAnnotationFix) + - createCopyAndReplaceAnnotationFixes(expectAnnotationEntry, castedDiagnostic.b, incompatibilityType) + createCopyAndReplaceAnnotationFixes(expectAnnotationEntry, castedDiagnostic.a, castedDiagnostic.b, incompatibilityType) } private fun createCopyAndReplaceAnnotationFixes( expectAnnotationEntry: KtAnnotationEntry, + expectDeclarationDescriptor: DeclarationDescriptor, actualDeclarationDescriptor: DeclarationDescriptor, incompatibilityType: ExpectActualAnnotationsIncompatibilityType, ): List> { + val expectDeclaration = expectDeclarationDescriptor.toSourceElement.getPsi() as? KtNamedDeclaration ?: return emptyList() val actualDeclaration = actualDeclarationDescriptor.toSourceElement.getPsi() as? KtNamedDeclaration ?: return emptyList() val mappedIncompatibilityType = incompatibilityType.mapAnnotationType { it.source.getPsi() as? KtAnnotationEntry } return ActualAnnotationsNotMatchExpectFixFactoryCommon.createCopyAndReplaceAnnotationFixes( + expectDeclaration, actualDeclaration, expectAnnotationEntry, mappedIncompatibilityType, diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiModuleTestGenerated.java b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiModuleTestGenerated.java index dcea470a9657..5b64cb08f2f8 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiModuleTestGenerated.java +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiModuleTestGenerated.java @@ -124,6 +124,16 @@ public abstract class QuickFixMultiModuleTestGenerated extends AbstractQuickFixM KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); } + @TestMetadata("copyNotSuggestedWhenActualFakeOverride") + public void testCopyNotSuggestedWhenActualFakeOverride() throws Exception { + runTest("testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualFakeOverride/"); + } + + @TestMetadata("copyNotSuggestedWhenActualTypealias") + public void testCopyNotSuggestedWhenActualTypealias() throws Exception { + runTest("testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualTypealias/"); + } + @TestMetadata("copyToActualConstExpression") public void testCopyToActualConstExpression() throws Exception { runTest("testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyToActualConstExpression/"); @@ -159,6 +169,21 @@ public abstract class QuickFixMultiModuleTestGenerated extends AbstractQuickFixM runTest("testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpect/"); } + @TestMetadata("removeFromExpectSuggestedWhenActualFakeOverride") + public void testRemoveFromExpectSuggestedWhenActualFakeOverride() throws Exception { + runTest("testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualFakeOverride/"); + } + + @TestMetadata("removeFromExpectSuggestedWhenActualHasNoSource") + public void testRemoveFromExpectSuggestedWhenActualHasNoSource() throws Exception { + runTest("testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualHasNoSource/"); + } + + @TestMetadata("removeFromExpectSuggestedWhenActualTypealias") + public void testRemoveFromExpectSuggestedWhenActualTypealias() throws Exception { + runTest("testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualTypealias/"); + } + @TestMetadata("replaceArgsOnActual") public void testReplaceArgsOnActual() throws Exception { runTest("testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/replaceArgsOnActual/"); diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualFakeOverride/common/common.kt b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualFakeOverride/common/common.kt new file mode 100644 index 000000000000..eca881055597 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualFakeOverride/common/common.kt @@ -0,0 +1,11 @@ +// DISABLE-ERRORS +annotation class Ann + +interface I { + fun foo() {} +} + +expect class Foo : I { + @Ann + override fun foo() +} diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualFakeOverride/dependencies.txt b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualFakeOverride/dependencies.txt new file mode 100644 index 000000000000..1d84fa9f0d66 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualFakeOverride/dependencies.txt @@ -0,0 +1,4 @@ +MODULE common { platform=[JVM, JS, Native]; root=common } +MODULE jvm { platform=[JVM]; root=jvm } + +jvm -> common { kind=DEPENDS_ON } diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualFakeOverride/jvm/jvm.kt b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualFakeOverride/jvm/jvm.kt new file mode 100644 index 000000000000..bca6a0f007d2 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualFakeOverride/jvm/jvm.kt @@ -0,0 +1,6 @@ +// "Copy mismatched annotation 'Ann' from expect to actual declaration (may change semantics)" "false" +// IGNORE_IRRELEVANT_ACTIONS +// DISABLE-ERRORS +// FIR_COMPARISON + +actual class Foo : I diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualTypealias/common/common.kt b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualTypealias/common/common.kt new file mode 100644 index 000000000000..9b9c793120c6 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualTypealias/common/common.kt @@ -0,0 +1,5 @@ +// DISABLE-ERRORS +annotation class Ann + +@Ann +expect class Foo diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualTypealias/dependencies.txt b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualTypealias/dependencies.txt new file mode 100644 index 000000000000..1d84fa9f0d66 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualTypealias/dependencies.txt @@ -0,0 +1,4 @@ +MODULE common { platform=[JVM, JS, Native]; root=common } +MODULE jvm { platform=[JVM]; root=jvm } + +jvm -> common { kind=DEPENDS_ON } diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualTypealias/jvm/jvm.kt b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualTypealias/jvm/jvm.kt new file mode 100644 index 000000000000..1a348d1dcd88 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/copyNotSuggestedWhenActualTypealias/jvm/jvm.kt @@ -0,0 +1,8 @@ +// "Copy mismatched annotation 'Ann' from expect to actual declaration (may change semantics)" "false" +// IGNORE_IRRELEVANT_ACTIONS +// DISABLE-ERRORS +// FIR_COMPARISON + +class FooImpl + +actual typealias Foo = FooImpl diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualFakeOverride/common/common.kt b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualFakeOverride/common/common.kt new file mode 100644 index 000000000000..eca881055597 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualFakeOverride/common/common.kt @@ -0,0 +1,11 @@ +// DISABLE-ERRORS +annotation class Ann + +interface I { + fun foo() {} +} + +expect class Foo : I { + @Ann + override fun foo() +} diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualFakeOverride/common/common.kt.after b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualFakeOverride/common/common.kt.after new file mode 100644 index 000000000000..c99380b9ca0c --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualFakeOverride/common/common.kt.after @@ -0,0 +1,10 @@ +// DISABLE-ERRORS +annotation class Ann + +interface I { + fun foo() {} +} + +expect class Foo : I { + override fun foo() +} diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualFakeOverride/dependencies.txt b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualFakeOverride/dependencies.txt new file mode 100644 index 000000000000..cab12bf6ffcc --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualFakeOverride/dependencies.txt @@ -0,0 +1,7 @@ +MODULE common { platform=[JVM, JS, Native]; root=common } +MODULE jvm { platform=[JVM]; root=jvm } + +common -> STDLIB_COMMON { kind=DEPENDENCY } +jvm -> common { kind=DEPENDS_ON } +jvm -> STDLIB_JVM { kind=DEPENDENCY } + diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualFakeOverride/jvm/jvm.kt b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualFakeOverride/jvm/jvm.kt new file mode 100644 index 000000000000..b06d92f26ead --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualFakeOverride/jvm/jvm.kt @@ -0,0 +1,5 @@ +// "Remove mismatched annotation 'Ann' from expect declaration (may change semantics)" "true" +// DISABLE-ERRORS +// FIR_COMPARISON + +actual class Foo : I diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualHasNoSource/common/common.kt b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualHasNoSource/common/common.kt new file mode 100644 index 000000000000..621491aee387 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualHasNoSource/common/common.kt @@ -0,0 +1,5 @@ +// DISABLE-ERRORS +annotation class Ann + +@Ann +expect annotation class CommonSynchronized diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualHasNoSource/common/common.kt.after b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualHasNoSource/common/common.kt.after new file mode 100644 index 000000000000..bf46e7758fe6 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualHasNoSource/common/common.kt.after @@ -0,0 +1,4 @@ +// DISABLE-ERRORS +annotation class Ann + +expect annotation class CommonSynchronized diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualHasNoSource/dependencies.txt b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualHasNoSource/dependencies.txt new file mode 100644 index 000000000000..2769ede81e95 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualHasNoSource/dependencies.txt @@ -0,0 +1,6 @@ +MODULE common { platform=[JVM, JS, Native]; root=common } +MODULE jvm { platform=[JVM]; root=jvm } + +common -> STDLIB_COMMON { kind=DEPENDENCY } +jvm -> common { kind=DEPENDS_ON } +jvm -> STDLIB_JVM { kind=DEPENDENCY } diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualHasNoSource/jvm/jvm.kt b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualHasNoSource/jvm/jvm.kt new file mode 100644 index 000000000000..320e17c919f2 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualHasNoSource/jvm/jvm.kt @@ -0,0 +1,5 @@ +// "Remove mismatched annotation 'Ann' from expect declaration (may change semantics)" "true" +// DISABLE-ERRORS +// FIR_COMPARISON + +actual typealias CommonSynchronized = kotlin.jvm.Synchronized diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualTypealias/common/common.kt b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualTypealias/common/common.kt new file mode 100644 index 000000000000..9b9c793120c6 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualTypealias/common/common.kt @@ -0,0 +1,5 @@ +// DISABLE-ERRORS +annotation class Ann + +@Ann +expect class Foo diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualTypealias/common/common.kt.after b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualTypealias/common/common.kt.after new file mode 100644 index 000000000000..7396992797a7 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualTypealias/common/common.kt.after @@ -0,0 +1,4 @@ +// DISABLE-ERRORS +annotation class Ann + +expect class Foo diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualTypealias/dependencies.txt b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualTypealias/dependencies.txt new file mode 100644 index 000000000000..1d84fa9f0d66 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualTypealias/dependencies.txt @@ -0,0 +1,4 @@ +MODULE common { platform=[JVM, JS, Native]; root=common } +MODULE jvm { platform=[JVM]; root=jvm } + +jvm -> common { kind=DEPENDS_ON } diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualTypealias/jvm/jvm.kt b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualTypealias/jvm/jvm.kt new file mode 100644 index 000000000000..f1b809309168 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/actualAnnotationsNotMatchExpect/removeFromExpectSuggestedWhenActualTypealias/jvm/jvm.kt @@ -0,0 +1,7 @@ +// "Remove mismatched annotation 'Ann' from expect declaration (may change semantics)" "true" +// DISABLE-ERRORS +// FIR_COMPARISON + +class FooImpl + +actual typealias Foo = FooImpl