| 1 |
import org.checkerframework.checker.nullness.qual.*; |
| 2 |
|
| 3 |
/* |
| 4 |
* Illustrate a problem with annotations on type variables. |
| 5 |
*/ |
| 6 |
public class GenericsBounds2<X extends @Nullable Object> { |
| 7 |
void m1(X @NonNull [] a1, @Nullable X @NonNull [] a2) { |
| 8 |
// :: error: (assignment.type.incompatible) |
| 9 |
a1 = null; |
| 10 |
// :: error: (assignment.type.incompatible) |
| 11 |
a1[0] = null; |
| 12 |
|
| 13 |
// :: error: (assignment.type.incompatible) |
| 14 |
a2 = null; |
| 15 |
a2[0] = null; |
| 16 |
|
| 17 |
// This error is expected when arrays are invariant. |
| 18 |
// Currently, this error is not raised. |
| 19 |
// TODOINVARR:: error: (assignment.type.incompatible) |
| 20 |
a2 = a1; |
| 21 |
a2[0] = null; |
| 22 |
} |
| 23 |
|
| 24 |
void aaa(@Nullable Object[] p1, @NonNull Object[] p2) { |
| 25 |
// This one is only expected when we switch the default for arrays to be invariant. |
| 26 |
// TODOINVARR:: error: (assignment.type.incompatible) |
| 27 |
p1 = p2; |
| 28 |
} |
| 29 |
} |