Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
msridhar committed Oct 9, 2024
1 parent 49652e4 commit 74740fe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
4 changes: 0 additions & 4 deletions nullaway/src/main/java/com/uber/nullaway/Nullness.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,6 @@ public static boolean paramHasNullableAnnotation(
if (symbol.isVarArgs()
&& paramInd == symbol.getParameters().size() - 1
&& !config.isLegacyAnnotationLocation()) {
// individual arguments passed in the varargs positions can be @Nullable if the array element
// type of the parameter is @Nullable
return NullabilityUtil.nullableVarargsElementsForSourceOrBytecode(
symbol.getParameters().get(paramInd), config);
} else {
Expand Down Expand Up @@ -270,8 +268,6 @@ public static boolean paramHasNonNullAnnotation(
if (symbol.isVarArgs()
&& paramInd == symbol.getParameters().size() - 1
&& !config.isLegacyAnnotationLocation()) {
// individual arguments passed in the varargs positions must be @NonNull if the array element
// type of the parameter is @NonNull
return NullabilityUtil.nonnullVarargsElementsForSourceOrBytecode(
symbol.getParameters().get(paramInd), config);
} else {
Expand Down
5 changes: 5 additions & 0 deletions nullaway/src/test/java/com/uber/nullaway/VarargsTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public void testNullableVarargs() {
.doTest();
}

/** Test for a @Nullable declaration annotation on a varargs parameter defined in bytecode */
@Test
public void nullableVarArgsFromBytecode() {
defaultCompilationHelper
Expand Down Expand Up @@ -532,6 +533,10 @@ public void testVarargsRestrictive() {
.doTest();
}

/**
* Test for a restrictive @NonNull declaration annotation on a varargs parameter defined in
* bytecode
*/
@Test
public void testVarargsRestrictiveBytecodes() {
makeTestHelperWithArgs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,5 @@

public class RestrictivelyAnnotatedVarargs {

public static void test(@Nonnull String... args) {
for (String arg : args) {
System.out.println(arg);
}
}
public static void test(@Nonnull String... args) {}
}

0 comments on commit 74740fe

Please sign in to comment.