Rename: Do not report shadowing conflict if redeclaration is detected
#KT-13240 Fixed
This commit is contained in:
@@ -266,6 +266,7 @@ Using 'this' as function argument in constructor of non-final class
|
|||||||
- [`KT-13239`](https://youtrack.jetbrains.com/issue/KT-13239) Rename: Warn about function name conflicts
|
- [`KT-13239`](https://youtrack.jetbrains.com/issue/KT-13239) Rename: Warn about function name conflicts
|
||||||
- [`KT-13174`](https://youtrack.jetbrains.com/issue/KT-13174) Move: Warn about accessibility conflicts due to moving to unrelated module
|
- [`KT-13174`](https://youtrack.jetbrains.com/issue/KT-13174) Move: Warn about accessibility conflicts due to moving to unrelated module
|
||||||
- [`KT-13175`](https://youtrack.jetbrains.com/issue/KT-13175) Move: Warn about accessibility conflicts when moving entire file
|
- [`KT-13175`](https://youtrack.jetbrains.com/issue/KT-13175) Move: Warn about accessibility conflicts when moving entire file
|
||||||
|
- [`KT-13240`](https://youtrack.jetbrains.com/issue/KT-13240) Rename: Do not report shadowing conflict if redeclaration is detected
|
||||||
|
|
||||||
##### New features
|
##### New features
|
||||||
|
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ fun reportShadowing(
|
|||||||
result: MutableList<UsageInfo>
|
result: MutableList<UsageInfo>
|
||||||
) {
|
) {
|
||||||
val candidate = DescriptorToSourceUtilsIde.getAnyDeclaration(declaration.project, candidateDescriptor) as? PsiNamedElement ?: return
|
val candidate = DescriptorToSourceUtilsIde.getAnyDeclaration(declaration.project, candidateDescriptor) as? PsiNamedElement ?: return
|
||||||
|
if (declaration.parent == candidate.parent) return
|
||||||
val message = "${declaration.renderDescription().capitalize()} will be shadowed by ${candidate.renderDescription()}"
|
val message = "${declaration.renderDescription().capitalize()} will be shadowed by ${candidate.renderDescription()}"
|
||||||
result += BasicUnresolvableCollisionUsageInfo(refElement, elementToBindUsageInfoTo, message)
|
result += BasicUnresolvableCollisionUsageInfo(refElement, elementToBindUsageInfoTo, message)
|
||||||
}
|
}
|
||||||
|
|||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
class /*rename*/SameScopeA { val contentA = 1 }
|
||||||
|
class SameScopeB { val contentB = 2 }
|
||||||
|
|
||||||
|
fun useClass() {
|
||||||
|
val va = SameScopeA().contentA
|
||||||
|
val vb = SameScopeB().contentB
|
||||||
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"type": "MARKED_ELEMENT",
|
||||||
|
"mainFile": "test.kt",
|
||||||
|
"newName": "SameScopeB",
|
||||||
|
"withRuntime": "true",
|
||||||
|
"hint": "Class 'SameScopeB' is already declared in package 'test'"
|
||||||
|
}
|
||||||
@@ -227,6 +227,12 @@ public class RenameTestGenerated extends AbstractRenameTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noShadowingConflictForSiblingDeclarations/noShadowingConflictForSiblingDeclarations.test")
|
||||||
|
public void testNoShadowingConflictForSiblingDeclarations_NoShadowingConflictForSiblingDeclarations() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/rename/noShadowingConflictForSiblingDeclarations/noShadowingConflictForSiblingDeclarations.test");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("parameterRedeclaration/parameterRedeclaration.test")
|
@TestMetadata("parameterRedeclaration/parameterRedeclaration.test")
|
||||||
public void testParameterRedeclaration_ParameterRedeclaration() throws Exception {
|
public void testParameterRedeclaration_ParameterRedeclaration() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/rename/parameterRedeclaration/parameterRedeclaration.test");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/rename/parameterRedeclaration/parameterRedeclaration.test");
|
||||||
|
|||||||
Reference in New Issue
Block a user