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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We need this due to our incomplete support for generics, and the fact that #765 fixes a previous
false negative which would cause our @NonNull model for Guava's Function to be ignored
when determining the correct overriding of the functional interface by a lambda.
will fail with an error about Function::apply having a @NonNull result. Where nullability should
actually depend on the parameter T of the ListenableFuture<T> in question.
Unfortunately, usage of this futures API is common internally for us, and our generics support is far
from fully supporting this in a sound manner, so this diff introduces a (hopefully temporary) workaround,
in the form of handler for the Futures/FluentFuture Guava APIs:
This works by special casing the return nullability of com.google.common.base.Function and com.google.common.util.concurrent.AsyncFunction to be e.g. Function<@Nullable T> whenever
these functional interfaces are implemented as a lambda expression passed to a list of specific
methods of com.google.common.util.concurrent.FluentFuture or com.google.common.util.concurrent.Futures. This is unsound, but permits the code example above to
pass NullAway checking, while strictly reducing the safety hole of NullAway versions prior to PR #765.
The reason will be displayed to describe this comment to others. Learn more.
One typo fix and this should be good to land. Approving assuming the typo will be fixed :-)
This is really a case where we need much deeper generics support, and we are just not there yet. Hopefully we can get closer soon.
I would ideally like to do perf benchmarking here, and I can't wait until #770 lands to make it easy! For now, based on reading the code I don't think it should have much perf impact, so we can go ahead and land.
This allows for a list of classes to be passed in via a command-line
argument `-XepOpt:NullAway:ExtraFuturesClasses`. Such classes will be
treated equivalently to built-in Guava Futures classes via the
`FluentFutureHandler`. This is a follow-up to #771.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We need this due to our incomplete support for generics, and the fact that #765 fixes a previous
false negative which would cause our
@NonNull
model for Guava'sFunction
to be ignoredwhen determining the correct overriding of the functional interface by a lambda.
After the fix, however, code such as:
will fail with an error about
Function::apply
having a@NonNull
result. Where nullability shouldactually depend on the parameter
T
of theListenableFuture<T>
in question.Unfortunately, usage of this futures API is common internally for us, and our generics support is far
from fully supporting this in a sound manner, so this diff introduces a (hopefully temporary) workaround,
in the form of handler for the Futures/FluentFuture Guava APIs:
This works by special casing the return nullability of
com.google.common.base.Function
andcom.google.common.util.concurrent.AsyncFunction
to be e.g.Function<@Nullable T>
wheneverthese functional interfaces are implemented as a lambda expression passed to a list of specific
methods of
com.google.common.util.concurrent.FluentFuture
orcom.google.common.util.concurrent.Futures
. This is unsound, but permits the code example above topass NullAway checking, while strictly reducing the safety hole of NullAway versions prior to PR #765.