diff --git a/nullaway/src/test/java/com/uber/nullaway/NullAwayTypeUseAnnotationsTests.java b/nullaway/src/test/java/com/uber/nullaway/NullAwayTypeUseAnnotationsTests.java index 7af8b253d4..5e13b02313 100644 --- a/nullaway/src/test/java/com/uber/nullaway/NullAwayTypeUseAnnotationsTests.java +++ b/nullaway/src/test/java/com/uber/nullaway/NullAwayTypeUseAnnotationsTests.java @@ -38,16 +38,28 @@ public void annotationAppliedToTypeParameter() { "import java.util.List;", "import java.util.ArrayList;", "import org.checkerframework.checker.nullness.qual.Nullable;", + "import org.checkerframework.checker.nullness.qual.NonNull;", "class TypeArgumentAnnotation {", " List<@Nullable String> fSafe = new ArrayList<>();", " @Nullable List fUnsafe = new ArrayList<>();", " void useParamSafe(List<@Nullable String> list) {", " list.hashCode();", " }", + " void unsafeCall() {", + " // BUG: Diagnostic contains: passing @Nullable parameter", + " useParamSafe(null);", + " }", " void useParamUnsafe(@Nullable List list) {", " // BUG: Diagnostic contains: dereferenced", " list.hashCode();", " }", + " void useParamUnsafeNonNullElements(@Nullable List<@NonNull String> list) {", + " // BUG: Diagnostic contains: dereferenced", + " list.hashCode();", + " }", + " void safeCall() {", + " useParamUnsafeNonNullElements(null);", + " }", " void useFieldSafe() {", " fSafe.hashCode();", " }",