blob: 5d316f7d8414c0bdb3cd91ae174aa3de7461231c [file] [log] [blame]
// Test case for Issue 319:
// https://github.com/typetools/checker-framework/issues/319
import org.checkerframework.checker.nullness.qual.*;
public class Issue319 {
class Foo<T> {
Foo(@Nullable T t) {}
}
<T> Foo<T> newFoo(@Nullable T t) {
return new Foo<>(t);
}
void pass() {
Foo<Boolean> f = newFoo(Boolean.FALSE);
}
void fail() {
Foo<Boolean> f = newFoo(null);
}
void workaround() {
Foo<Boolean> f = Issue319.this.<Boolean>newFoo(null);
}
}
class Issue319NN {
class Foo<T> {
Foo(@NonNull T t) {}
}
<T> Foo<T> newFoo(@NonNull T t) {
return new Foo<>(t);
}
void pass() {
Foo<Boolean> f = newFoo(Boolean.FALSE);
}
void fail() {
// :: error: (argument)
Foo<Boolean> f = newFoo(null);
}
void pass2() {
Foo<@Nullable Boolean> f = newFoo(Boolean.FALSE);
}
}