mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IG: don't report static equals() methods as covariant (IDEA-165075)
This commit is contained in:
+4
-2
@@ -50,7 +50,9 @@ public class CovariantEqualsInspection extends BaseInspection {
|
||||
|
||||
@Override
|
||||
public void visitMethod(@NotNull PsiMethod method) {
|
||||
// note: no call to super
|
||||
if (method.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
return;
|
||||
}
|
||||
final String name = method.getName();
|
||||
if (!HardcodedMethodConstants.EQUALS.equals(name)) {
|
||||
return;
|
||||
@@ -74,7 +76,7 @@ public class CovariantEqualsInspection extends BaseInspection {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (SuperMethodsSearch.search(method, null, true, false).findFirst() != null) {
|
||||
if (MethodUtils.hasSuper(method)) {
|
||||
return;
|
||||
}
|
||||
registerMethodError(method);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<html>
|
||||
<body>
|
||||
Reports a class having a <b>equals()</b>
|
||||
method taking an argument other than <b>java.lang.Object</b>, if the class does not have a <b>equals()</b> method
|
||||
which does take <b>java.lang.Object</b> as its argument. Normally, this is a mistake.
|
||||
Reports <b>equals()</b> methods taking an argument type other than <b>java.lang.Object</b>.
|
||||
Only reports if the containing class does not have another <b>equals()</b> method
|
||||
which does take <b>java.lang.Object</b> as its argument type. Normally, this is a mistake.
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
|
||||
|
||||
+9
@@ -33,4 +33,13 @@ class E {
|
||||
boolean <warning descr="'equals()' should take 'Object' as its argument">equals</warning>(E e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
abstract class Condition {
|
||||
static Condition equals(String value) {
|
||||
return new Condition() {
|
||||
// some implementation here
|
||||
};
|
||||
}
|
||||
|
||||
// more abstract methods
|
||||
}
|
||||
Reference in New Issue
Block a user