IDEA-170214 Properly handle Bean Validation inheritance in @NotNull/@Nullable problems inspection

This commit is contained in:
peter
2017-03-28 19:01:55 +02:00
parent d2aa1f7e39
commit e8ac7110c0
3 changed files with 30 additions and 5 deletions
@@ -0,0 +1,13 @@
import javax.annotation.constraints.*;
interface Intf {
@NotNull Object foo(@NotNull Object p);
}
class Impl implements Intf {
@Override
public Object foo(Object p) {
return p;
}
}
@@ -115,7 +115,7 @@ public class NullableStuffInspectionTest extends LightCodeInsightFixtureTestCase
DataFlowInspectionTest.addJavaxDefaultNullabilityAnnotations(myFixture);
myFixture.addFileToProject("foo/package-info.java", "@javax.annotation.ParametersAreNonnullByDefault package foo;");
myFixture.addClass("import javax.annotation.*; package foo; public interface NullableFunction { void fun(@Nullable Object o); }");
myFixture.addClass("package foo; import javax.annotation.*; public interface NullableFunction { void fun(@Nullable Object o); }");
myFixture.addClass("package foo; public interface AnyFunction { void fun(Object o); }");
doTest();
@@ -195,4 +195,11 @@ public class NullableStuffInspectionTest extends LightCodeInsightFixtureTestCase
myFixture.checkHighlighting(true, false, true);
}
public void testBeanValidationNotNull() {
myFixture.addClass("package javax.annotation.constraints; public @interface NotNull{}");
DataFlowInspection8Test.setCustomAnnotations(getProject(), getTestRootDisposable(), "javax.annotation.constraints.NotNull", "javax.annotation.constraints.Nullable");
myInspection.REPORT_ANNOTATION_NOT_PROPAGATED_TO_OVERRIDERS = true;
doTest();
}
}