empty method: ensure super call is not removed if unrelated defaults are present (IDEA-202410)

This commit is contained in:
Anna.Kozlova
2018-11-19 14:22:53 +01:00
parent aaff178c0c
commit 306beee6e1
2 changed files with 22 additions and 0 deletions

View File

@@ -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;