mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
push down: don't push methods overriding non-abstract supers (IDEA-191189)
This commit is contained in:
+9
-2
@@ -237,8 +237,15 @@ public class JavaPushDownDelegate extends PushDownDelegate<MemberInfo, PsiMember
|
||||
}
|
||||
else if (member instanceof PsiMethod) {
|
||||
PsiMethod method = (PsiMethod)member;
|
||||
PsiMethod methodBySignature = MethodSignatureUtil.findMethodBySuperSignature(targetClass, method.getSignature(substitutor), false);
|
||||
if (methodBySignature == null) {
|
||||
PsiMethod methodBySignature = MethodSignatureUtil.findMethodBySuperSignature(targetClass, method.getSignature(substitutor), true);
|
||||
boolean pushMethodToClass = methodBySignature == null;
|
||||
if (!pushMethodToClass) {
|
||||
//non-abstract method inherited from super class
|
||||
PsiClass containingClass = methodBySignature.getContainingClass();
|
||||
pushMethodToClass = containingClass == sourceClass ||
|
||||
containingClass != targetClass && methodBySignature.hasModifierProperty(PsiModifier.ABSTRACT);
|
||||
}
|
||||
if (pushMethodToClass) {
|
||||
newMember = (PsiMethod)targetClass.add(method);
|
||||
final PsiMethod oldMethod = (PsiMethod)memberInfo.getMember();
|
||||
if (sourceClass.isInterface() && !targetClass.isInterface()) {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
interface A {
|
||||
void <caret>m();
|
||||
}
|
||||
|
||||
abstract class B extends A {
|
||||
public void m() {
|
||||
//do something
|
||||
}
|
||||
}
|
||||
|
||||
class C extends B implements A {}
|
||||
@@ -0,0 +1,10 @@
|
||||
interface A {
|
||||
}
|
||||
|
||||
abstract class B extends A {
|
||||
public void m() {
|
||||
//do something
|
||||
}
|
||||
}
|
||||
|
||||
class C extends B implements A {}
|
||||
@@ -75,12 +75,12 @@ public class PushDownTest extends LightRefactoringTestCase {
|
||||
|
||||
public void testDefaultMethodToInterface() {doTest();}
|
||||
public void testDefaultMethodToInterfaceKeepAbstract() {doTestImplements(true);}
|
||||
public void testThisSuperExpressions() {doTest();}
|
||||
public void testDefaultMethodToClass() {doTest();}
|
||||
public void testDefaultMethodToClassKeepAbstract() { doTestImplements(true); }
|
||||
|
||||
public void testInterfaceStaticMethodToInterface() { doTest(); }
|
||||
public void testInterfaceStaticMethodToClass() { doTest(); }
|
||||
public void testThisSuperExpressions() {doTest();}
|
||||
public void testMethodsInheritedFromSuper() {doTest();}
|
||||
|
||||
public void testInterfaceMethodToClass() { doTest();}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user