You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
../../base/android/java/src/org/chromium/base/shared_preferences/SharedPreferencesManager.java:206: warning: [NullAway] Method readStringSet has @Contract(_, !null -> !null), but this appears to be violated, as a @Nullable value may be returned when parameter defaultValue is non-null.
return null;
^
(see http://t.uber.com/nullaway )
1 warning
However, if I remove the unmodifiableSet part, it succeeds:
Note that values is determined to be non-null as a result of a nullImpliesNullParameters() library model here. I'm guessing the data flow analysis is not recognizing that if (values != null) is always true when defaultValue != null
The text was updated successfully, but these errors were encountered:
Sorry for the slow response. I think this is in a similar category to #98 and #1112. Here, I think the issue is that the dataflow analysis does not prune out infeasible paths. Like in the second example, if defaultValue is non-null, then the final return null statement becomes unreachable. Here is a simpler example:
// this method can never return nullpublicObjectfoo() {
Objectx = newObject();
if (x != null) {
returnx;
}
returnnull; // NullAway reports a false positive here
}
The Checker Framework Nullness Checker also reports a false positive for code like the above. We will try to look at this eventually (it might not be too hard to fix), but for now issues like #98 will be higher priority.
msridhar
changed the title
False-positive in @Contract check when a nullImpliesNullParameters-derived value is used in a conditional
NullAway dataflow analysis does not prune out infeasible paths
Jan 1, 2025
In the context of this code review, I found:
// Complains that the contract is not satisfied
// Also complains:
The error is:
However, if I remove the
unmodifiableSet
part, it succeeds:Note that
values
is determined to be non-null as a result of anullImpliesNullParameters()
library model here. I'm guessing the data flow analysis is not recognizing thatif (values != null)
is always true whendefaultValue != null
The text was updated successfully, but these errors were encountered: