IG: ignore method if removing it would break compilation (IDEA-185066)

This commit is contained in:
Bas Leijdekkers
2018-01-21 17:39:32 +01:00
parent d867dbfb0d
commit 84e4ac4c32
2 changed files with 21 additions and 5 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2005-2017 Bas Leijdekkers
* Copyright 2005-2018 Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -86,14 +86,15 @@ public class RedundantMethodOverrideInspection extends BaseInspection {
public void visitMethod(PsiMethod method) {
super.visitMethod(method);
final PsiCodeBlock body = method.getBody();
if (body == null) {
if (body == null || method.getNameIdentifier() == null) {
return;
}
if (method.getNameIdentifier() == null) {
final PsiMethod[] methods = method.findSuperMethods();
if (methods.length == 0) {
return;
}
final PsiMethod superMethod = MethodUtils.getSuper(method);
if (superMethod == null) {
final PsiMethod superMethod = methods[0];
if (superMethod.hasModifierProperty(PsiModifier.DEFAULT) && methods.length > 1) {
return;
}
if (!MethodUtils.haveEquivalentModifierLists(method, superMethod)) {
@@ -145,3 +145,18 @@ class Annotations2 extends Annotations1{
super.m();
}
}
///////////////
interface XX {
void x();
}
interface YY {
default void x() {
System.out.println();
}
}
class ZZ implements YY, XX {
@Override
public void x() {
YY.super.x();
}
}