diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspectionBase.java b/java/java-analysis-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspectionBase.java
index cc69b340cf76..b32011af1aaa 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspectionBase.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspectionBase.java
@@ -923,6 +923,10 @@ public class NullableStuffInspectionBase extends AbstractBaseJavaLocalInspection
private static boolean isSuperNotAnnotated(NullableNotNullManager nullableManager, PsiParameter parameter, PsiParameter superParameter) {
if (hasNullability(nullableManager, superParameter)) return false;
+ if (ContainerUtil.exists(getSuperAnnotationOwners(superParameter),
+ superSuperParameter -> hasNullability(nullableManager, superSuperParameter))) {
+ return false;
+ }
PsiType type = superParameter.getType();
if (TypeUtils.isTypeParameter(type)) {
PsiClass childClass = PsiUtil.getContainingClass(parameter);
diff --git a/java/java-tests/testData/inspection/nullableProblems/NoNotNullWarningIfIndirectSuperMethodIsAnnotated.java b/java/java-tests/testData/inspection/nullableProblems/NoNotNullWarningIfIndirectSuperMethodIsAnnotated.java
new file mode 100644
index 000000000000..c400d39ce146
--- /dev/null
+++ b/java/java-tests/testData/inspection/nullableProblems/NoNotNullWarningIfIndirectSuperMethodIsAnnotated.java
@@ -0,0 +1,26 @@
+import org.jetbrains.annotations.NotNull;
+
+class Foo {
+ interface I {
+ // Warning: "Overriding method parameters are not annotated", expected
+ void m(@NotNull String s);
+ }
+
+ static class S implements I {
+ @Override
+ // Warning: "Not annotated parameter overrides @NotNull parameter", expected
+ public void m(String s) {
+ System.out.println(s);
+ }
+ }
+
+ static class C extends S {
+ @Override
+ // Warning: "Parameter annotated @NotNull should not override non-annotated parameter"
+ // undesired if we have no control over the S superclass.
+ // Having annotation is still preferred here
+ public void m(@NotNull String s) {
+ super.m(s);
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/java/codeInspection/NullableStuffInspectionTest.java b/java/java-tests/testSrc/com/intellij/java/codeInspection/NullableStuffInspectionTest.java
index 791a0eb94e42..70c82a9107d2 100644
--- a/java/java-tests/testSrc/com/intellij/java/codeInspection/NullableStuffInspectionTest.java
+++ b/java/java-tests/testSrc/com/intellij/java/codeInspection/NullableStuffInspectionTest.java
@@ -434,4 +434,10 @@ public class NullableStuffInspectionTest extends LightJavaCodeInsightFixtureTest
DataFlowInspectionTestCase.addJetBrainsNotNullByDefault(myFixture);
doTest();
}
+
+ public void testNoNotNullWarningIfIndirectSuperMethodIsAnnotated() {
+ myInspection.REPORT_ANNOTATION_NOT_PROPAGATED_TO_OVERRIDERS = true;
+ myInspection.REPORT_NOTNULL_PARAMETERS_OVERRIDES_NOT_ANNOTATED = true;
+ doTest();
+ }
}
\ No newline at end of file