mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-165372 (Incorrect suggestion to remove "super" qualifier)
This commit is contained in:
+2
-1
@@ -26,6 +26,7 @@ import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.psiutils.MethodUtils;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -129,7 +130,7 @@ public class UnnecessarySuperQualifierInspection extends BaseInspection implemen
|
||||
|
||||
private static boolean hasUnnecessarySuperQualifier(PsiMethodCallExpression methodCallExpression) {
|
||||
final PsiMethod superMethod = methodCallExpression.resolveMethod();
|
||||
if (superMethod == null) {
|
||||
if (superMethod == null || MethodUtils.isOverridden(superMethod)) {
|
||||
return false;
|
||||
}
|
||||
// check that super.m() and m() resolve to the same method
|
||||
|
||||
+31
-1
@@ -20,7 +20,7 @@ public class UnnecessarySuperQualifier {
|
||||
|
||||
private static class Up extends Base<String> {
|
||||
void foo() {
|
||||
<warning descr="Qualifier 'super' is unnecessary in this context">super</warning>.test("asfd");
|
||||
super.test("asfd");
|
||||
System.out.println(<warning descr="Qualifier 'super' is unnecessary in this context">super</warning>.field);
|
||||
}
|
||||
}
|
||||
@@ -80,4 +80,34 @@ public class UnnecessarySuperQualifier {
|
||||
return String.valueOf(<warning descr="Qualifier 'super' is unnecessary in this context">super</warning>.f);
|
||||
}
|
||||
}
|
||||
}
|
||||
class BugSuper {
|
||||
public void close() {
|
||||
System.out.println("BugSuper.close()");
|
||||
}
|
||||
public static void main(String[] arg) {
|
||||
try {
|
||||
BugSuper bug = new Next2();
|
||||
bug.close();
|
||||
} catch(Throwable t) {
|
||||
System.out.println("ERROR: " + t);
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Next1 extends BugSuper {
|
||||
public void closeall() {
|
||||
System.out.println("Next1.closeall()");
|
||||
// IDEA Intellij is suggesting: Remove unnecessary "super" qualifier.
|
||||
// Try to remove yourself :-)
|
||||
super.close();
|
||||
}
|
||||
}
|
||||
|
||||
class Next2 extends Next1 {
|
||||
public void close() {
|
||||
System.out.println("Next2.close()");
|
||||
closeall();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user