import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.checkerframework.checker.nullness.qual.*;
class Utils {
void test(List super A> list, A object) {
list.add(object);
}
interface Consumer {
public void consume(A object);
}
public static Consumer cast(
final Consumer<@Nullable ? super A> consumer) {
return new Consumer() {
@Override
public void consume(A object) {
consumer.consume(object);
}
};
}
public static Consumer getConsumer(
Consumer<@Nullable Object> nullConsumer) {
return Utils.cast(nullConsumer);
}
Map> mss = new HashMap<>();
Set> foo() {
Set> l = new HashSet<>(this.foo());
return l;
}
}
class MyGeneric<@NonNull T extends @Nullable Number> {}
class UseMyGeneric {
MyGeneric> wildcardUnbounded = new MyGeneric<>();
// :: error: (assignment.type.incompatible)
MyGeneric extends @NonNull Object> wildcardOutsideUB = wildcardUnbounded;
MyGeneric extends @NonNull Number> wildcardInsideUB = wildcardOutsideUB;
// :: error: (assignment.type.incompatible)
MyGeneric extends @NonNull Number> wildcardInsideUB2 = wildcardUnbounded;
MyGeneric extends @Nullable Number> wildcardInsideUBNullable = wildcardOutsideUB;
}
class MyGenericExactBounds<@NonNull T extends @NonNull Number> {}
class UseMyGenericExactBounds {
// :: error: (type.argument.type.incompatible)
MyGenericExactBounds extends @Nullable Object> wildcardOutsideUBError =
new MyGenericExactBounds<>();
MyGenericExactBounds extends @NonNull Object> wildcardOutside = new MyGenericExactBounds<>();
MyGenericExactBounds extends @NonNull Number> wildcardInsideUB = wildcardOutside;
MyGenericExactBounds> wildcardOutsideUB = wildcardOutside;
}