Change Signature: Do not report conflict of object member with itself (available through the class object)

#KT-6345 Fixed
This commit is contained in:
Alexey Sedunov
2014-12-09 12:14:05 +03:00
parent 6bbe9b2bfe
commit 14b33f8b95
5 changed files with 26 additions and 2 deletions
@@ -199,6 +199,10 @@ public class JetChangeInfo implements ChangeInfo {
newParameters.add(parameterInfo); newParameters.add(parameterInfo);
} }
public void removeParameter(int index) {
newParameters.remove(index);
}
@Override @Override
public boolean isParameterSetOrOrderChanged() { public boolean isParameterSetOrOrderChanged() {
if (parameterNamesChanged == null) if (parameterNamesChanged == null)
@@ -216,8 +216,12 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro
if (!changeInfo.isConstructor() && functionScope != null && !info.getNewName().isEmpty()) { if (!changeInfo.isConstructor() && functionScope != null && !info.getNewName().isEmpty()) {
for (FunctionDescriptor conflict : functionScope.getFunctions(Name.identifier(info.getNewName()))) { for (FunctionDescriptor conflict : functionScope.getFunctions(Name.identifier(info.getNewName()))) {
if (conflict != oldDescriptor && getFunctionParameterTypes(conflict).equals(getFunctionParameterTypes(oldDescriptor))) { if (conflict == oldDescriptor) continue;
PsiElement conflictElement = DescriptorToSourceUtils.descriptorToDeclaration(conflict);
PsiElement conflictElement = DescriptorToSourceUtils.descriptorToDeclaration(conflict);
if (conflictElement == changeInfo.getMethod()) continue;
if (getFunctionParameterTypes(conflict).equals(getFunctionParameterTypes(oldDescriptor))) {
result.putValue(conflictElement, "Function already exists: '" + DescriptorRenderer.SHORT_NAMES_IN_TYPES.render(conflict) + "'"); result.putValue(conflictElement, "Function already exists: '" + DescriptorRenderer.SHORT_NAMES_IN_TYPES.render(conflict) + "'");
break; break;
} }
@@ -0,0 +1,5 @@
object O {
fun foo() {
}
}
@@ -0,0 +1,5 @@
object O {
fun <caret>foo(name: String) {
}
}
@@ -567,6 +567,12 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase {
doTest(changeInfo); doTest(changeInfo);
} }
public void testObjectMember() throws Exception {
JetChangeInfo changeInfo = getChangeInfo();
changeInfo.removeParameter(0);
doTest(changeInfo);
}
@NotNull @NotNull
@Override @Override
protected String getTestDataPath() { protected String getTestDataPath() {