예제 #1
0
 void testArr1b(@Nullable Object @Nullable [] a) {
   // one way to use as a cast:
   @NonNull Object[] l2 = NullnessUtil.castNonNullDeep(a);
   // Careful, the non-deep version only casts the main modifier.
   // :: error: (assignment.type.incompatible)
   @NonNull Object[] l2b = NullnessUtil.castNonNull(a);
   // OK
   @Nullable Object[] l2c = NullnessUtil.castNonNull(a);
 }
예제 #2
0
 void testArr3(@Nullable Object @NonNull [] a) {
   // use as statement:
   NullnessUtil.castNonNullDeep(a);
   a.toString();
   // TODO: @EnsuresNonNull cannot express that
   // all the array components are non-null.
   // a[0].toString();
 }
예제 #3
0
 void testMultiArr2(@Nullable Object @NonNull [] @Nullable [] a) {
   // another way to use as a cast:
   NullnessUtil.castNonNullDeep(a)[0][0].toString();
 }
예제 #4
0
 void testMultiArr1(@Nullable Object @NonNull [] @Nullable [] a) {
   // :: error: (assignment.type.incompatible) :: error: (accessing.nullable)
   @NonNull Object l3 = a[0][0];
   // one way to use as a cast:
   @NonNull Object[][] l4 = NullnessUtil.castNonNullDeep(a);
 }
예제 #5
0
 void testRef1(@Nullable Object o) {
   // one way to use as a cast:
   @NonNull Object l1 = NullnessUtil.castNonNull(o);
 }
예제 #6
0
 void testRef3(@Nullable Object o) {
   // use as statement:
   NullnessUtil.castNonNull(o);
   o.toString();
 }
예제 #7
0
 public static void main(String[] args) {
   Object[] @Nullable [] err = new Object[10][10];
   Object[][] e1 = NullnessUtil.castNonNullDeep(err);
   e1[0][0].toString();
 }
예제 #8
0
 void testRef2(@Nullable Object o) {
   // another way to use as a cast:
   NullnessUtil.castNonNull(o).toString();
 }
예제 #9
0
 void testMultiArr3(@Nullable Object @Nullable [] @Nullable [] @Nullable [] a) {
   // :: error: (dereference.of.nullable) :: error: (accessing.nullable)
   a[0][0][0].toString();
   // another way to use as a cast:
   NullnessUtil.castNonNullDeep(a)[0][0][0].toString();
 }