Move: Account for implemented modules in internal access check
#KT-23590 Fixed
This commit is contained in:
+3
-2
@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.descriptors.*
|
|||||||
import org.jetbrains.kotlin.descriptors.impl.MutablePackageFragmentDescriptor
|
import org.jetbrains.kotlin.descriptors.impl.MutablePackageFragmentDescriptor
|
||||||
import org.jetbrains.kotlin.idea.caches.project.getModuleInfoByVirtualFile
|
import org.jetbrains.kotlin.idea.caches.project.getModuleInfoByVirtualFile
|
||||||
import org.jetbrains.kotlin.idea.caches.project.forcedModuleInfo
|
import org.jetbrains.kotlin.idea.caches.project.forcedModuleInfo
|
||||||
|
import org.jetbrains.kotlin.idea.caches.project.implementedModules
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.*
|
import org.jetbrains.kotlin.idea.caches.resolve.*
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.util.getJavaMemberDescriptor
|
import org.jetbrains.kotlin.idea.caches.resolve.util.getJavaMemberDescriptor
|
||||||
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
||||||
@@ -483,8 +484,8 @@ class MoveConflictChecker(
|
|||||||
for (memberToCheck in membersToCheck) {
|
for (memberToCheck in membersToCheck) {
|
||||||
for (reference in ReferencesSearch.search(memberToCheck)) {
|
for (reference in ReferencesSearch.search(memberToCheck)) {
|
||||||
val element = reference.element ?: continue
|
val element = reference.element ?: continue
|
||||||
val usageModule = ModuleUtilCore.findModuleForPsiElement(element)
|
val usageModule = ModuleUtilCore.findModuleForPsiElement(element) ?: continue
|
||||||
if (usageModule != targetModule && !isToBeMoved(element)) {
|
if (usageModule != targetModule && targetModule !in usageModule.implementedModules && !isToBeMoved(element)) {
|
||||||
val container = element.getUsageContext()
|
val container = element.getUsageContext()
|
||||||
val message = "${render(container)} uses internal ${render(memberToCheck)} which will be inaccessible after move"
|
val message = "${render(container)} uses internal ${render(memberToCheck)} which will be inaccessible after move"
|
||||||
conflicts.putValue(element, message.capitalize())
|
conflicts.putValue(element, message.capitalize())
|
||||||
|
|||||||
Vendored
+21
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="kotlin-language" name="Kotlin">
|
||||||
|
<configuration version="3" platform="Common (experimental) " useProjectSettings="false">
|
||||||
|
<compilerSettings />
|
||||||
|
<compilerArguments>
|
||||||
|
<option name="multiPlatform" value="true" />
|
||||||
|
</compilerArguments>
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
open class Foo {
|
||||||
|
internal fun bar() = ""
|
||||||
|
}
|
||||||
Vendored
+23
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="module" module-name="A" scope="COMPILE" />
|
||||||
|
</component>
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="kotlin-language" name="Kotlin">
|
||||||
|
<configuration version="3" platform="JVM 1.8" useProjectSettings="false">
|
||||||
|
<implements>A</implements>
|
||||||
|
<compilerSettings />
|
||||||
|
<compilerArguments>
|
||||||
|
<option name="multiPlatform" value="true" />
|
||||||
|
</compilerArguments>
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
class Bar : Foo() {
|
||||||
|
val x = bar()
|
||||||
|
}
|
||||||
Vendored
+21
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="kotlin-language" name="Kotlin">
|
||||||
|
<configuration version="3" platform="Common (experimental) " useProjectSettings="false">
|
||||||
|
<compilerSettings />
|
||||||
|
<compilerArguments>
|
||||||
|
<option name="multiPlatform" value="true" />
|
||||||
|
</compilerArguments>
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
Vendored
+23
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="module" module-name="A" scope="COMPILE" />
|
||||||
|
</component>
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="kotlin-language" name="Kotlin">
|
||||||
|
<configuration version="3" platform="JVM 1.8" useProjectSettings="false">
|
||||||
|
<implements>A</implements>
|
||||||
|
<compilerSettings />
|
||||||
|
<compilerArguments>
|
||||||
|
<option name="multiPlatform" value="true" />
|
||||||
|
</compilerArguments>
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
open class <caret>Foo {
|
||||||
|
internal fun bar() = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
class Bar : Foo() {
|
||||||
|
val x = bar()
|
||||||
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"mainFile": "B/src/test.kt",
|
||||||
|
"type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS",
|
||||||
|
"targetPackage": "",
|
||||||
|
"targetSourceRoot": "A/src",
|
||||||
|
"withRuntime": "true"
|
||||||
|
}
|
||||||
+5
@@ -29,6 +29,11 @@ public class MultiModuleMoveTestGenerated extends AbstractMultiModuleMoveTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentInSingleGeneratedClass(this.getClass(), new File("idea/testData/refactoring/moveMultiModule"), Pattern.compile("^(.+)\\.test$"), TargetBackend.ANY);
|
KotlinTestUtils.assertAllTestsPresentInSingleGeneratedClass(this.getClass(), new File("idea/testData/refactoring/moveMultiModule"), Pattern.compile("^(.+)\\.test$"), TargetBackend.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("moveClassWithInternalMemberFromJvmToCommon/moveClassWithInternalMemberFromJvmToCommon.test")
|
||||||
|
public void testMoveClassWithInternalMemberFromJvmToCommon_MoveClassWithInternalMemberFromJvmToCommon() throws Exception {
|
||||||
|
runTest("idea/testData/refactoring/moveMultiModule/moveClassWithInternalMemberFromJvmToCommon/moveClassWithInternalMemberFromJvmToCommon.test");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("moveDirectoryKeepPackageDirective/moveDirectoryKeepPackageDirective.test")
|
@TestMetadata("moveDirectoryKeepPackageDirective/moveDirectoryKeepPackageDirective.test")
|
||||||
public void testMoveDirectoryKeepPackageDirective_MoveDirectoryKeepPackageDirective() throws Exception {
|
public void testMoveDirectoryKeepPackageDirective_MoveDirectoryKeepPackageDirective() throws Exception {
|
||||||
runTest("idea/testData/refactoring/moveMultiModule/moveDirectoryKeepPackageDirective/moveDirectoryKeepPackageDirective.test");
|
runTest("idea/testData/refactoring/moveMultiModule/moveDirectoryKeepPackageDirective/moveDirectoryKeepPackageDirective.test");
|
||||||
|
|||||||
Reference in New Issue
Block a user