| 1 |
import org.checkerframework.checker.nullness.qual.*; |
| 2 |
|
| 3 |
interface GBList<E extends @Nullable Object> { |
| 4 |
void add(E p); |
| 5 |
} |
| 6 |
|
| 7 |
/* |
| 8 |
* Illustrate a problem with annotations on type variables. |
| 9 |
* The annotation on the upper bound of a type variable is confused with an |
| 10 |
* annotation on the type variable itself. |
| 11 |
*/ |
| 12 |
public class GenericsBounds1<X extends @Nullable Object> { |
| 13 |
void m1(@NonNull GBList<X> g1, @NonNull GBList<@Nullable X> g2) { |
| 14 |
// :: error: (assignment.type.incompatible) |
| 15 |
g1 = null; |
| 16 |
// :: error: (argument.type.incompatible) |
| 17 |
g1.add(null); |
| 18 |
|
| 19 |
// :: error: (assignment.type.incompatible) |
| 20 |
g2 = null; |
| 21 |
g2.add(null); |
| 22 |
|
| 23 |
// :: error: (assignment.type.incompatible) |
| 24 |
g2 = g1; |
| 25 |
g2.add(null); |
| 26 |
} |
| 27 |
} |