mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
empty method: ensure super call is not removed if unrelated defaults are present (IDEA-202410)
This commit is contained in:
@@ -566,11 +566,18 @@ public class RefJavaUtilImpl extends RefJavaUtil {
|
||||
|
||||
if (hasStatements) {
|
||||
final PsiMethod[] superMethods = javaMethod.findSuperMethods();
|
||||
int defaultCount = 0;
|
||||
for (PsiMethod superMethod : superMethods) {
|
||||
if (VisibilityUtil.compare(VisibilityUtil.getVisibilityModifier(superMethod.getModifierList()),
|
||||
VisibilityUtil.getVisibilityModifier(javaMethod.getModifierList())) > 0) {
|
||||
return false;
|
||||
}
|
||||
if (superMethod.hasModifierProperty(PsiModifier.DEFAULT)) {
|
||||
defaultCount++;
|
||||
}
|
||||
}
|
||||
if (defaultCount > 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return hasStatements;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
interface Interface1 {
|
||||
default void foo() { System.out.println("Interface1.foo()"); }
|
||||
}
|
||||
|
||||
interface Interface2 {
|
||||
default void foo() { System.out.println("Interface2.foo()"); }
|
||||
}
|
||||
|
||||
interface Interface3 extends Interface1, Interface2 {
|
||||
default void foo() {
|
||||
Interface1.super.foo();
|
||||
Interface2.super.foo();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user