change signature: show conflicts if delegated method has same erasure as initial one (IDEA-157672)

This commit is contained in:
Anna Kozlova
2016-06-30 21:02:38 +03:00
parent 1af51530f4
commit 41998a977e
4 changed files with 14 additions and 3 deletions
@@ -1002,7 +1002,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
LOG.error(e);
}
}
checkContract(conflictDescriptions, myChangeInfo.getMethod());
for (UsageInfo usageInfo : usagesSet) {
@@ -1104,7 +1104,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
prototype.getParameterList().add(param);
}
ConflictsUtil.checkMethodConflicts(method.getContainingClass(), method, prototype, conflicts);
ConflictsUtil.checkMethodConflicts(method.getContainingClass(), myChangeInfo.isGenerateDelegate() ? null : method, prototype, conflicts);
}
catch (IncorrectOperationException e) {
LOG.error(e);
@@ -53,7 +53,7 @@ public class ConflictsUtil {
}
public static void checkMethodConflicts(@Nullable PsiClass aClass,
PsiMethod refactoredMethod,
@Nullable PsiMethod refactoredMethod,
final PsiMethod prototype,
final MultiMap<PsiElement,String> conflicts) {
if (prototype == null) return;
@@ -0,0 +1,3 @@
class A {
void <caret>m() {}
}
@@ -52,6 +52,14 @@ public class ChangeSignatureTest extends ChangeSignatureBaseTest {
catch (BaseRefactoringProcessor.ConflictsInTestsException ignored) { }
}
public void testDelegateWithoutChangesWarnAboutSameMethodInClass() throws Exception {
try {
doTest(null, new ParameterInfoImpl[0], true);
fail("Conflict expected");
}
catch (BaseRefactoringProcessor.ConflictsInTestsException ignored) { }
}
public void testGenericTypes() {
doTest(null, null, "T", method -> new ParameterInfoImpl[]{
new ParameterInfoImpl(-1, "x", myFactory.createTypeFromText("T", method.getParameterList()), "null"),