Move/Copy: Fix 'protected' conflict reporting for references in super type entries
#KT-22678 Fixed
This commit is contained in:
+6
-2
@@ -392,8 +392,12 @@ class MoveConflictChecker(
|
|||||||
val targetVisibility = visibility.normalize()
|
val targetVisibility = visibility.normalize()
|
||||||
if (targetVisibility == Visibilities.PUBLIC) return true
|
if (targetVisibility == Visibilities.PUBLIC) return true
|
||||||
|
|
||||||
val referrer = ref.element.getStrictParentOfType<KtNamedDeclaration>()
|
val refElement = ref.element
|
||||||
val referrerDescriptor = referrer?.unsafeResolveToDescriptor() ?: return true
|
val referrer = refElement.getStrictParentOfType<KtNamedDeclaration>()
|
||||||
|
var referrerDescriptor = referrer?.resolveToDescriptorIfAny() ?: return true
|
||||||
|
if (referrerDescriptor is ClassDescriptor && refElement.getParentOfTypeAndBranch<KtSuperTypeListEntry> { typeReference } != null) {
|
||||||
|
referrerDescriptor.unsubstitutedPrimaryConstructor?.let { referrerDescriptor = it }
|
||||||
|
}
|
||||||
|
|
||||||
if (!isVisibleIn(referrerDescriptor)) return true
|
if (!isVisibleIn(referrerDescriptor)) return true
|
||||||
|
|
||||||
|
|||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package bar
|
||||||
|
|
||||||
|
class Test2(name: String) : TestBase(name)
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
class Test(name: String) : TestBase(name)
|
||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package foo;
|
||||||
|
|
||||||
|
public class TestBase {
|
||||||
|
protected TestBase(final String test) {}
|
||||||
|
}
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
class <caret>Test(name: String) : TestBase(name)
|
||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package foo;
|
||||||
|
|
||||||
|
public class TestBase {
|
||||||
|
protected TestBase(final String test) {}
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"mainFile": "foo/Test.kt",
|
||||||
|
"targetPackage": "bar",
|
||||||
|
"newName": "Test2"
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package bar
|
||||||
|
|
||||||
|
import foo.TestBase
|
||||||
|
|
||||||
|
class Test(name: String) : TestBase(name)
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package foo;
|
||||||
|
|
||||||
|
public class TestBase {
|
||||||
|
protected TestBase(final String test) {}
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
class <caret>Test(name: String) : TestBase(name)
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package foo;
|
||||||
|
|
||||||
|
public class TestBase {
|
||||||
|
protected TestBase(final String test) {}
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"mainFile": "foo/Test.kt",
|
||||||
|
"type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS",
|
||||||
|
"targetPackage": "bar"
|
||||||
|
}
|
||||||
@@ -211,6 +211,12 @@ public class CopyTestGenerated extends AbstractCopyTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("protectedConstructorRefInSuperListEntry/protectedConstructorRefInSuperListEntry.test")
|
||||||
|
public void testProtectedConstructorRefInSuperListEntry_ProtectedConstructorRefInSuperListEntry() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/copy/protectedConstructorRefInSuperListEntry/protectedConstructorRefInSuperListEntry.test");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("refToImportJavaStaticField/refToImportedJavaStaticField.test")
|
@TestMetadata("refToImportJavaStaticField/refToImportedJavaStaticField.test")
|
||||||
public void testRefToImportJavaStaticField_RefToImportedJavaStaticField() throws Exception {
|
public void testRefToImportJavaStaticField_RefToImportedJavaStaticField() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/copy/refToImportJavaStaticField/refToImportedJavaStaticField.test");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/copy/refToImportJavaStaticField/refToImportedJavaStaticField.test");
|
||||||
|
|||||||
@@ -661,6 +661,12 @@ public class MoveTestGenerated extends AbstractMoveTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kotlin/moveTopLevelDeclarations/misc/protectedConstructorRefInSuperListEntry/protectedConstructorRefInSuperListEntry.test")
|
||||||
|
public void testKotlin_moveTopLevelDeclarations_misc_protectedConstructorRefInSuperListEntry_ProtectedConstructorRefInSuperListEntry() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/protectedConstructorRefInSuperListEntry/protectedConstructorRefInSuperListEntry.test");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kotlin/moveTopLevelDeclarations/misc/protectedMembersExternalRefs/protectedMembersExternalRefs.test")
|
@TestMetadata("kotlin/moveTopLevelDeclarations/misc/protectedMembersExternalRefs/protectedMembersExternalRefs.test")
|
||||||
public void testKotlin_moveTopLevelDeclarations_misc_protectedMembersExternalRefs_ProtectedMembersExternalRefs() throws Exception {
|
public void testKotlin_moveTopLevelDeclarations_misc_protectedMembersExternalRefs_ProtectedMembersExternalRefs() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/protectedMembersExternalRefs/protectedMembersExternalRefs.test");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/protectedMembersExternalRefs/protectedMembersExternalRefs.test");
|
||||||
|
|||||||
Reference in New Issue
Block a user