| 1 |
package nullness.generics; |
| 2 |
|
| 3 |
// see also framework/tests/all-systems/WildcardSuper2 |
| 4 |
|
| 5 |
import java.util.List; |
| 6 |
import org.checkerframework.checker.nullness.qual.NonNull; |
| 7 |
|
| 8 |
interface ToOverride<T> { |
| 9 |
// For nullness this should default to type @NonNull List<? [ extends @Nullable Object |
| 10 |
// super @NonNull T ]> |
| 11 |
public abstract int transform(List<? super T> function); |
| 12 |
} |
| 13 |
|
| 14 |
class WildcardOverride implements ToOverride<Object> { |
| 15 |
// invalid because the overriden method takes @Nullable args and this one doesn't |
| 16 |
@Override |
| 17 |
// :: error: (override.param.invalid) |
| 18 |
public int transform(List<Object> function) { |
| 19 |
return 0; |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
interface ToOverride2<T> { |
| 24 |
// For nullness this should be typed as |
| 25 |
// @NonNull List<? [ extends @NonNull Object super T [ extends @Nullable super @NonNull ]> |
| 26 |
// :: error: (bound.type.incompatible) |
| 27 |
public abstract int transform(List<@NonNull ? super T> function); |
| 28 |
} |
| 29 |
|
| 30 |
class WildcardOverride2 implements ToOverride2<Object> { |
| 31 |
// valid because the overriden method takes ONLY @NonNull args and this one takes @NonNull args |
| 32 |
// as well |
| 33 |
@Override |
| 34 |
public int transform(List<Object> function) { |
| 35 |
return 0; |
| 36 |
} |
| 37 |
} |