diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/expectactual/AbstractCreateDeclarationFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/expectactual/AbstractCreateDeclarationFix.kt index 6c62d5a1d78..9c4cbfcb250 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/expectactual/AbstractCreateDeclarationFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/expectactual/AbstractCreateDeclarationFix.kt @@ -68,7 +68,7 @@ abstract class AbstractCreateDeclarationFix( val packageDirective = originalFile.packageDirective if (packageDirective != null) { val oldPackageDirective = targetFile.packageDirective - val newPackageDirective = factory.createPackageDirective(packageDirective.fqName) + val newPackageDirective = packageDirective.copy() as KtPackageDirective if (oldPackageDirective != null) { oldPackageDirective.replace(newPackageDirective) } else { diff --git a/idea/testData/multiModuleQuickFix/createActualWithRootPackage/common/path/My.kt b/idea/testData/multiModuleQuickFix/createActualWithRootPackage/common/path/My.kt new file mode 100644 index 00000000000..862f932d9a7 --- /dev/null +++ b/idea/testData/multiModuleQuickFix/createActualWithRootPackage/common/path/My.kt @@ -0,0 +1,4 @@ +// "Create actual class for module testModule_JVM (JVM)" "true" +// DISABLE-ERRORS + +expect class My \ No newline at end of file diff --git a/idea/testData/multiModuleQuickFix/createActualWithRootPackage/common/path/My.kt.after b/idea/testData/multiModuleQuickFix/createActualWithRootPackage/common/path/My.kt.after new file mode 100644 index 00000000000..d52613e94ee --- /dev/null +++ b/idea/testData/multiModuleQuickFix/createActualWithRootPackage/common/path/My.kt.after @@ -0,0 +1,4 @@ +// "Create actual class for module testModule_JVM (JVM)" "true" +// DISABLE-ERRORS + +expect class My \ No newline at end of file diff --git a/idea/testData/multiModuleQuickFix/createActualWithRootPackage/jvm/path/My.kt.after b/idea/testData/multiModuleQuickFix/createActualWithRootPackage/jvm/path/My.kt.after new file mode 100644 index 00000000000..5d2e6b0aa48 --- /dev/null +++ b/idea/testData/multiModuleQuickFix/createActualWithRootPackage/jvm/path/My.kt.after @@ -0,0 +1 @@ +actual class My \ No newline at end of file diff --git a/idea/testData/multiModuleQuickFix/createExpectWithRootPackage/common/path/My.kt.after.kt b/idea/testData/multiModuleQuickFix/createExpectWithRootPackage/common/path/My.kt.after.kt new file mode 100644 index 00000000000..9f0e7818bca --- /dev/null +++ b/idea/testData/multiModuleQuickFix/createExpectWithRootPackage/common/path/My.kt.after.kt @@ -0,0 +1 @@ +expect class `My.kt.after` \ No newline at end of file diff --git a/idea/testData/multiModuleQuickFix/createExpectWithRootPackage/jvm/path/My.kt b/idea/testData/multiModuleQuickFix/createExpectWithRootPackage/jvm/path/My.kt new file mode 100644 index 00000000000..625184aff6d --- /dev/null +++ b/idea/testData/multiModuleQuickFix/createExpectWithRootPackage/jvm/path/My.kt @@ -0,0 +1,4 @@ +// "Create expected class in common module testModule_Common" "true" +// DISABLE-ERRORS + +actual class My \ No newline at end of file diff --git a/idea/testData/multiModuleQuickFix/createExpectWithRootPackage/jvm/path/My.kt.after b/idea/testData/multiModuleQuickFix/createExpectWithRootPackage/jvm/path/My.kt.after new file mode 100644 index 00000000000..b97fdfa44e2 --- /dev/null +++ b/idea/testData/multiModuleQuickFix/createExpectWithRootPackage/jvm/path/My.kt.after @@ -0,0 +1,4 @@ +// "Create expected class in common module testModule_Common" "true" +// DISABLE-ERRORS + +actual class My \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiModuleTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiModuleTestGenerated.java index d3013c002df..ce0186d306d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiModuleTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiModuleTestGenerated.java @@ -204,6 +204,11 @@ public class QuickFixMultiModuleTestGenerated extends AbstractQuickFixMultiModul runTest("idea/testData/multiModuleQuickFix/convertPropertyToFunction/"); } + @TestMetadata("createActualWithRootPackage") + public void testCreateActualWithRootPackage() throws Exception { + runTest("idea/testData/multiModuleQuickFix/createActualWithRootPackage/"); + } + @TestMetadata("createClassFromUsageImport") public void testCreateClassFromUsageImport() throws Exception { runTest("idea/testData/multiModuleQuickFix/createClassFromUsageImport/"); @@ -214,6 +219,11 @@ public class QuickFixMultiModuleTestGenerated extends AbstractQuickFixMultiModul runTest("idea/testData/multiModuleQuickFix/createClassFromUsageRef/"); } + @TestMetadata("createExpectWithRootPackage") + public void testCreateExpectWithRootPackage() throws Exception { + runTest("idea/testData/multiModuleQuickFix/createExpectWithRootPackage/"); + } + @TestMetadata("createFunInExpectClass") public void testCreateFunInExpectClass() throws Exception { runTest("idea/testData/multiModuleQuickFix/createFunInExpectClass/");