diff --git a/idea/idea-test-framework/test/org/jetbrains/kotlin/idea/test/ConfigLibraryUtil.kt b/idea/idea-test-framework/test/org/jetbrains/kotlin/idea/test/ConfigLibraryUtil.kt
index 5e5027e9f3f..8b1b2273d19 100644
--- a/idea/idea-test-framework/test/org/jetbrains/kotlin/idea/test/ConfigLibraryUtil.kt
+++ b/idea/idea-test-framework/test/org/jetbrains/kotlin/idea/test/ConfigLibraryUtil.kt
@@ -29,6 +29,7 @@ import com.intellij.openapi.roots.libraries.Library
import com.intellij.openapi.roots.libraries.PersistentLibraryKind
import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor
import com.intellij.openapi.vfs.VfsUtil
+import org.jetbrains.kotlin.idea.framework.CommonLibraryKind
import org.jetbrains.kotlin.idea.framework.JSLibraryKind
import org.jetbrains.kotlin.idea.util.application.runWriteAction
import org.jetbrains.kotlin.test.InTextDirectivesUtils
@@ -44,6 +45,7 @@ object ConfigLibraryUtil {
private val DEFAULT_JAVA_RUNTIME_LIB_NAME = "JAVA_RUNTIME_LIB_NAME"
private val DEFAULT_KOTLIN_TEST_LIB_NAME = "KOTLIN_TEST_LIB_NAME"
private val DEFAULT_KOTLIN_JS_STDLIB_NAME = "KOTLIN_JS_STDLIB_NAME"
+ private val DEFAULT_KOTLIN_COMMON_STDLIB_NAME = "KOTLIN_COMMON_STDLIB_NAME"
private fun getKotlinRuntimeLibEditor(libName: String, library: File): NewLibraryEditor {
val editor = NewLibraryEditor()
@@ -65,6 +67,17 @@ object ConfigLibraryUtil {
JSLibraryKind)
}
+ fun configureKotlinCommonRuntime(module: Module) {
+ addLibrary(
+ getKotlinRuntimeLibEditor(
+ DEFAULT_KOTLIN_COMMON_STDLIB_NAME,
+ File("dist/common/kotlin-stdlib-common.jar")
+ ),
+ module,
+ CommonLibraryKind
+ )
+ }
+
fun configureKotlinRuntime(module: Module) {
addLibrary(getKotlinRuntimeLibEditor(DEFAULT_JAVA_RUNTIME_LIB_NAME, PathUtil.kotlinPathsForDistDirectory.stdlibPath), module)
addLibrary(getKotlinRuntimeLibEditor(DEFAULT_KOTLIN_TEST_LIB_NAME, PathUtil.kotlinPathsForDistDirectory.kotlinTestPath), module)
@@ -85,6 +98,10 @@ object ConfigLibraryUtil {
removeLibrary(module, DEFAULT_KOTLIN_JS_STDLIB_NAME)
}
+ fun unConfigureKotlinCommonRuntime(module: Module) {
+ removeLibrary(module, DEFAULT_KOTLIN_COMMON_STDLIB_NAME)
+ }
+
fun configureSdk(module: Module, sdk: Sdk) {
ApplicationManager.getApplication().runWriteAction {
val rootManager = ModuleRootManager.getInstance(module)
diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/moveConflictUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/moveConflictUtils.kt
index 66e27c4ee0b..5e51230284d 100644
--- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/moveConflictUtils.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/moveConflictUtils.kt
@@ -285,8 +285,6 @@ class MoveConflictChecker(
val fqName = targetDescriptor.importableFqName ?: return true
val importableDescriptor = targetDescriptor.getImportableDescriptor()
- val renderedImportableTarget = DESCRIPTOR_RENDERER_FOR_COMPARISON.render(importableDescriptor)
- val renderedTarget by lazy { DESCRIPTOR_RENDERER_FOR_COMPARISON.render(targetDescriptor) }
val targetModuleInfo = getModuleInfoByVirtualFile(project, targetScope)
val dummyFile = KtPsiFactory(targetElement.project).createFile("dummy.kt", "").apply {
@@ -296,6 +294,14 @@ class MoveConflictChecker(
val newTargetDescriptors = dummyFile.resolveImportReference(fqName)
+ if (importableDescriptor is TypeAliasDescriptor
+ && newTargetDescriptors.any {
+ it is ClassDescriptor && it.isExpect && it.importableFqName == importableDescriptor.importableFqName
+ }) return true
+
+ val renderedImportableTarget = DESCRIPTOR_RENDERER_FOR_COMPARISON.render(importableDescriptor)
+ val renderedTarget by lazy { DESCRIPTOR_RENDERER_FOR_COMPARISON.render(targetDescriptor) }
+
return newTargetDescriptors.any {
if (DESCRIPTOR_RENDERER_FOR_COMPARISON.render(it) != renderedImportableTarget) return@any false
if (importableDescriptor == targetDescriptor) return@any true
diff --git a/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/after/A/A.iml b/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/after/A/A.iml
new file mode 100644
index 00000000000..341197fc9b5
--- /dev/null
+++ b/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/after/A/A.iml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/after/A/src/Foo.kt b/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/after/A/src/Foo.kt
new file mode 100644
index 00000000000..50fc9ca12f2
--- /dev/null
+++ b/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/after/A/src/Foo.kt
@@ -0,0 +1,5 @@
+class Foo {
+ fun foo() {
+ throw IllegalStateException()
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/after/A/src/dummy.txt b/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/after/A/src/dummy.txt
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/after/B/B.iml b/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/after/B/B.iml
new file mode 100644
index 00000000000..d2add8adf60
--- /dev/null
+++ b/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/after/B/B.iml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ A
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/after/B/src/test.kt b/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/after/B/src/test.kt
new file mode 100644
index 00000000000..4a643c4dde8
--- /dev/null
+++ b/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/after/B/src/test.kt
@@ -0,0 +1 @@
+class Bar
\ No newline at end of file
diff --git a/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/before/A/A.iml b/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/before/A/A.iml
new file mode 100644
index 00000000000..341197fc9b5
--- /dev/null
+++ b/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/before/A/A.iml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/before/A/src/dummy.txt b/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/before/A/src/dummy.txt
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/before/B/B.iml b/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/before/B/B.iml
new file mode 100644
index 00000000000..d2add8adf60
--- /dev/null
+++ b/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/before/B/B.iml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ A
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/before/B/src/test.kt b/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/before/B/src/test.kt
new file mode 100644
index 00000000000..e9745ae8381
--- /dev/null
+++ b/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/before/B/src/test.kt
@@ -0,0 +1,7 @@
+class Foo {
+ fun foo() {
+ throw IllegalStateException()
+ }
+}
+
+class Bar
\ No newline at end of file
diff --git a/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/moveRefToLibTypeAliasImplementingLibExpectClass.test b/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/moveRefToLibTypeAliasImplementingLibExpectClass.test
new file mode 100644
index 00000000000..a30b6548bd1
--- /dev/null
+++ b/idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/moveRefToLibTypeAliasImplementingLibExpectClass.test
@@ -0,0 +1,9 @@
+{
+ "mainFile": "B/src/test.kt",
+ "type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS",
+ "targetPackage": "",
+ "targetSourceRoot": "A/src",
+ "withRuntime": "true",
+ "modulesWithRuntime": ["B"],
+ "modulesWithCommonRuntime": ["A"]
+}
diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/AbstractMultiModuleMoveTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/AbstractMultiModuleMoveTest.kt
index f58e7a2283e..032c01dd012 100644
--- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/AbstractMultiModuleMoveTest.kt
+++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/AbstractMultiModuleMoveTest.kt
@@ -37,6 +37,7 @@ abstract class AbstractMultiModuleMoveTest : KotlinMultiFileTestCase() {
doTestCommittingDocuments { rootDir, _ ->
val modulesWithJvmRuntime: List
val modulesWithJsRuntime: List
+ val modulesWithCommonRuntime: List
PluginTestCaseBase.addJdk(testRootDisposable, PluginTestCaseBase::mockJdk)
@@ -45,16 +46,22 @@ abstract class AbstractMultiModuleMoveTest : KotlinMultiFileTestCase() {
val moduleManager = ModuleManager.getInstance(project)
modulesWithJvmRuntime =
(config["modulesWithRuntime"]?.asJsonArray?.map { moduleManager.findModuleByName(it.asString!!)!! }
- ?: moduleManager.modules.toList())
+ ?: moduleManager.modules.toList())
modulesWithJvmRuntime.forEach { ConfigLibraryUtil.configureKotlinRuntimeAndSdk(it, PluginTestCaseBase.mockJdk()) }
+
modulesWithJsRuntime =
(config["modulesWithJsRuntime"]?.asJsonArray?.map { moduleManager.findModuleByName(it.asString!!)!! }
- ?: emptyList())
+ ?: emptyList())
modulesWithJsRuntime.forEach { ConfigLibraryUtil.configureKotlinJsRuntimeAndSdk(it, PluginTestCaseBase.mockJdk()) }
- }
- else {
+
+ modulesWithCommonRuntime =
+ (config["modulesWithCommonRuntime"]?.asJsonArray?.map { moduleManager.findModuleByName(it.asString!!)!! }
+ ?: emptyList())
+ modulesWithCommonRuntime.forEach { ConfigLibraryUtil.configureKotlinCommonRuntime(it) }
+ } else {
modulesWithJvmRuntime = emptyList()
modulesWithJsRuntime = emptyList()
+ modulesWithCommonRuntime = emptyList()
}
try {
@@ -67,6 +74,9 @@ abstract class AbstractMultiModuleMoveTest : KotlinMultiFileTestCase() {
modulesWithJsRuntime.forEach {
ConfigLibraryUtil.unConfigureKotlinJsRuntimeAndSdk(it, PluginTestCaseBase.mockJdk())
}
+ modulesWithCommonRuntime.forEach {
+ ConfigLibraryUtil.unConfigureKotlinCommonRuntime(it)
+ }
}
}
}
diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MultiModuleMoveTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MultiModuleMoveTestGenerated.java
index e31f1a8d199..aed238dee2c 100644
--- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MultiModuleMoveTestGenerated.java
+++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MultiModuleMoveTestGenerated.java
@@ -84,6 +84,11 @@ public class MultiModuleMoveTestGenerated extends AbstractMultiModuleMoveTest {
runTest("idea/testData/refactoring/moveMultiModule/movePackageToUnrelatedModuleConflict/movePackageToUnrelatedModuleConflict.test");
}
+ @TestMetadata("moveRefToLibTypeAliasImplementingLibExpectClass/moveRefToLibTypeAliasImplementingLibExpectClass.test")
+ public void testMoveRefToLibTypeAliasImplementingLibExpectClass_MoveRefToLibTypeAliasImplementingLibExpectClass() throws Exception {
+ runTest("idea/testData/refactoring/moveMultiModule/moveRefToLibTypeAliasImplementingLibExpectClass/moveRefToLibTypeAliasImplementingLibExpectClass.test");
+ }
+
@TestMetadata("moveToModuleWithoutLibConflict/moveToModuleWithoutLibConflict.test")
public void testMoveToModuleWithoutLibConflict_MoveToModuleWithoutLibConflict() throws Exception {
runTest("idea/testData/refactoring/moveMultiModule/moveToModuleWithoutLibConflict/moveToModuleWithoutLibConflict.test");