In this case, a @Nullable field is stored to a local variable. When the field is used in a null condition an error occurs, but if the variable is used then it does not. It seems the data flow analysis does not realize they are the same.
error: [NullAway] returning @Nullable expression from method with @NonNull return type
return (writer == null) ? CacheWriter.disabledWriter() : castedWriter;
^
<K1 extends K, V1 extends V> CacheWriter<K1, V1> getCacheWriter() {
@SuppressWarnings("unchecked")
CacheWriter<K1, V1> castedWriter = (CacheWriter<K1, V1>) writer;
return (writer == null) ? CacheWriter.disabledWriter() : castedWriter;
}
In this case, a
@Nullablefield is stored to a local variable. When the field is used in a null condition an error occurs, but if the variable is used then it does not. It seems the data flow analysis does not realize they are the same.