Java: don't add abstract modifier to interface methods when pulling up methods

GitOrigin-RevId: df0c5de380b00f2d42e073a15f4472d52cb34470
This commit is contained in:
Bas Leijdekkers
2023-01-27 16:00:45 +00:00
committed by intellij-monorepo-bot
parent 3cd88edfd3
commit f30035d655
4 changed files with 24 additions and 1 deletions
@@ -383,7 +383,9 @@ public final class RefactoringUtil {
body.delete();
}
PsiUtil.setModifierProperty(method, PsiModifier.ABSTRACT, true);
if (!targetClass.isInterface()) {
PsiUtil.setModifierProperty(method, PsiModifier.ABSTRACT, true);
}
}
if (!targetClass.isInterface()) {
@@ -0,0 +1,8 @@
interface Foo1 {
void foo();
}
class Bar implements Foo1 {
public void <caret>foo() {
System.out.println("hello");
}
}
@@ -0,0 +1,9 @@
interface Foo1 {
void foo();
}
class Bar implements Foo1 {
@Override
public void foo() {
System.out.println("hello");
}
}
@@ -35,6 +35,10 @@ public class PullUpTest extends LightRefactoringTestCase {
doTest(new RefactoringTestUtil.MemberDescriptor("foo", PsiMethod.class, true));
}
public void testNoAbstractModifiersOnInterfaceMethods() {
doTest(new RefactoringTestUtil.MemberDescriptor("foo", PsiMethod.class, true));
}
public void testQualifiedReference() { // IDEADEV-25008
doTest(new RefactoringTestUtil.MemberDescriptor("x", PsiField.class),
new RefactoringTestUtil.MemberDescriptor("getX", PsiMethod.class),