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:
peter
2017-01-18 19:42:15 +01:00
parent ab22b9b3ac
commit 59bdc4b5ab
2 changed files with 5 additions and 2 deletions
@@ -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);
}
@@ -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) { }
}