mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-166444 Good code yellow: Not annotated method with primitive return type is used as an override for a method annotated with NotNull
This commit is contained in:
+1
@@ -476,6 +476,7 @@ public class NullableStuffInspectionBase extends BaseJavaBatchLocalInspectionToo
|
||||
|
||||
private boolean isNonAnnotatedOverridingNotNull(PsiMethod method, PsiMethod superMethod) {
|
||||
return REPORT_NOT_ANNOTATED_METHOD_OVERRIDES_NOTNULL &&
|
||||
!(method.getReturnType() instanceof PsiPrimitiveType) &&
|
||||
!getNullityManager(method).hasNullability(method) &&
|
||||
isNotNullNotInferred(superMethod, true, IGNORE_EXTERNAL_SUPER_NOTNULL);
|
||||
}
|
||||
|
||||
+4
-2
@@ -3,7 +3,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
interface NonnullInterface {
|
||||
@NotNull
|
||||
String nonNullMethod();
|
||||
Object nonNullMethod();
|
||||
}
|
||||
|
||||
class P2 {
|
||||
@@ -17,7 +17,7 @@ class P2 {
|
||||
}
|
||||
});
|
||||
test(this::<warning descr="Method annotated with @Nullable must not override @NotNull method">getNull</warning>);
|
||||
test(this::<warning descr="Not annotated method is used as an override for a method annotated with NotNull">getNonAnnotated</warning>);
|
||||
test(this::getPrimitive);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -25,5 +25,7 @@ class P2 {
|
||||
|
||||
String getNonAnnotated() { return null; }
|
||||
|
||||
boolean getPrimitive() { return true; }
|
||||
|
||||
private void test(final NonnullInterface function) { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user