Change Signature: Do not report conflict of object member with itself (available through the class object)
#KT-6345 Fixed
This commit is contained in:
@@ -199,6 +199,10 @@ public class JetChangeInfo implements ChangeInfo {
|
||||
newParameters.add(parameterInfo);
|
||||
}
|
||||
|
||||
public void removeParameter(int index) {
|
||||
newParameters.remove(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isParameterSetOrOrderChanged() {
|
||||
if (parameterNamesChanged == null)
|
||||
|
||||
+6
-2
@@ -216,8 +216,12 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro
|
||||
|
||||
if (!changeInfo.isConstructor() && functionScope != null && !info.getNewName().isEmpty()) {
|
||||
for (FunctionDescriptor conflict : functionScope.getFunctions(Name.identifier(info.getNewName()))) {
|
||||
if (conflict != oldDescriptor && getFunctionParameterTypes(conflict).equals(getFunctionParameterTypes(oldDescriptor))) {
|
||||
PsiElement conflictElement = DescriptorToSourceUtils.descriptorToDeclaration(conflict);
|
||||
if (conflict == oldDescriptor) continue;
|
||||
|
||||
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) + "'");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
object O {
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
object O {
|
||||
fun <caret>foo(name: String) {
|
||||
|
||||
}
|
||||
}
|
||||
+6
@@ -567,6 +567,12 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase {
|
||||
doTest(changeInfo);
|
||||
}
|
||||
|
||||
public void testObjectMember() throws Exception {
|
||||
JetChangeInfo changeInfo = getChangeInfo();
|
||||
changeInfo.removeParameter(0);
|
||||
doTest(changeInfo);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
|
||||
Reference in New Issue
Block a user