You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Syntax of 2d arrays is tricky, so I might be holding it wrong...
importorg.jspecify.annotations.Nullable;
importorg.jspecify.annotations.NullMarked;
importstaticorg.chromium.build.NullUtil.assumeNonNull;
@NullMarkedclassFoo {
// nullable array of non-null arrays of non-null objects.Object@Nullable [][] arr1 = newObject[3][4];
// nullable array of non-nullable arrays of nullable objects.@NullableObject@Nullable [][] arr2 = newObject[3][4];
@NullableObject[][] arr3 = newObject[3][4];
publicvoidbug() {
assumeNonNull(arr1);
for (inti = 0; i < arr1.length; ++i) {
for (intj = 0; j < arr1[i].length; j++) {
System.out.println(arr1[i][j]);
}
}
assumeNonNull(arr2);
for (inti = 0; i < arr2.length; ++i) {
for (intj = 0; j < arr2[i].length; j++) {
System.out.println(arr2[i][j]);
}
}
for (inti = 0; i < arr3.length; ++i) {
for (intj = 0; j < arr3[i].length; j++) {
System.out.println(arr3[i][j]);
}
}
}
}
Foo.java:11: warning: [NullAway] Cannot assign from type Object[][] to type @Nullable Object[][] due to mismatched nullability of type parameters
@Nullable Object @Nullable [][] arr2 = new Object[3][4];
^
(see http://t.uber.com/nullaway )
Foo.java:12: warning: [NullAway] Cannot assign from type Object[][] to type @Nullable Object[][] due to mismatched nullability of type parameters
@Nullable Object[][] arr3 = new Object[3][4];
^
(see http://t.uber.com/nullaway )
Foo.java:26: warning: [NullAway] dereferenced expression arr2[i] is @Nullable
for (int j = 0; j < arr2[i].length; j++) {
^
(see http://t.uber.com/nullaway )
Foo.java:32: warning: [NullAway] dereferenced expression arr3[i] is @Nullable
for (int j = 0; j < arr3[i].length; j++) {
^
(see http://t.uber.com/nullaway )
4 warnings
The only difference between arr1 and arr2 is whether the element type is nullable, but changing that triggers warnings about the nullness of the array (no warnings exist for arr1). arr3 has only a nullable element type, but triggers the same warnings.
The text was updated successfully, but these errors were encountered:
Syntax of 2d arrays is tricky, so I might be holding it wrong...
The only difference between
arr1
andarr2
is whether the element type is nullable, but changing that triggers warnings about the nullness of the array (no warnings exist forarr1
).arr3
has only a nullable element type, but triggers the same warnings.The text was updated successfully, but these errors were encountered: