It would be nice if the checker could detect that 'test' being true implies 'o'
is non-null.
=== Test.java ===
import javax.annotation.Nullable;
abstract class Test {
abstract @Nullable Object n();
void f(boolean flag) {
Object o = n();
boolean test = o != null;
if (test) {
g(o);
}
}
void g(Object o) {}
}
===
$ javac -version -processor
org.checkerframework.checker.nullness.NullnessChecker Test.java
javac 1.8.0-jsr308-1.8.11
Test.java:10: error: [argument.type.incompatible] incompatible types in
argument.
g(o);
^
found : @Initialized @Nullable Object
required: @Initialized @NonNull Object
1 error
Original issue reported on code.google.com by cus...@google.com on 5 Mar 2015 at 3:44
Original issue reported on code.google.com by
cus...@google.com
on 5 Mar 2015 at 3:44