Rename: Fix parameter rename when new name matches call selector

#KT-13476 Fixed
This commit is contained in:
Alexey Sedunov
2016-08-16 17:17:32 +03:00
parent 5e577c391c
commit f507eed42d
6 changed files with 33 additions and 1 deletions
+1
View File
@@ -274,6 +274,7 @@ Using 'this' as function argument in constructor of non-final class
- [`KT-13124`](https://youtrack.jetbrains.com/issue/KT-13124) Pull Up: Skip super members without explicit declarations
- [`KT-13032`](https://youtrack.jetbrains.com/issue/KT-13032) Rename: Support accessors with non-conventional names
- [`KT-13463`](https://youtrack.jetbrains.com/issue/KT-13463) Rename: Quote parameter name when necessary
- [`KT-13476`](https://youtrack.jetbrains.com/issue/KT-13476) Rename: Fix parameter rename when new name matches call selector
##### New features
@@ -171,6 +171,7 @@ fun reportShadowing(
result += BasicUnresolvableCollisionUsageInfo(refElement, elementToBindUsageInfoTo, message)
}
// todo: break into smaller functions
private fun checkUsagesRetargeting(
elementToBindUsageInfosTo: PsiElement,
declaration: PsiNamedElement,
@@ -287,7 +288,9 @@ private fun checkUsagesRetargeting(
continue
}
usageIterator.set(UsageInfoWithReplacement(fullCallExpression, declaration, qualifiedExpression))
if (fullCallExpression !is KtQualifiedExpression) {
usageIterator.set(UsageInfoWithReplacement(fullCallExpression, declaration, qualifiedExpression))
}
}
}
@@ -0,0 +1,8 @@
interface I {
fun some()
}
fun f(some: I) {
println(some)
some.some()
}
@@ -0,0 +1,8 @@
interface I {
fun some()
}
fun f(/*rename*/o: I) {
println(o)
o.some()
}
@@ -0,0 +1,6 @@
{
"type": "MARKED_ELEMENT",
"mainFile": "test/test.kt",
"newName": "some",
"withRuntime": "true"
}
@@ -239,6 +239,12 @@ public class RenameTestGenerated extends AbstractRenameTest {
doTest(fileName);
}
@TestMetadata("paramererAsReceiverWithNewNameAsSelector/parameterAsReceiverWithNewNameAsSelector.test")
public void testParamererAsReceiverWithNewNameAsSelector_ParameterAsReceiverWithNewNameAsSelector() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/rename/paramererAsReceiverWithNewNameAsSelector/parameterAsReceiverWithNewNameAsSelector.test");
doTest(fileName);
}
@TestMetadata("parameterRedeclaration/parameterRedeclaration.test")
public void testParameterRedeclaration_ParameterRedeclaration() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/rename/parameterRedeclaration/parameterRedeclaration.test");