We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm trying to pass a @NonNull value where the nullness checker expects @Nullable. This seems safe to me but I get an error.
@NonNull
@Nullable
commands: checker-framework-3.19.0/checker/bin/javac -processor nullness NullnessCheckerDemo.java
checker-framework-3.19.0/checker/bin/javac -processor nullness NullnessCheckerDemo.java
inputs: NullnessCheckerDemo.java:
NullnessCheckerDemo.java
package com.google.nullnesscheckerdemo; import java.util.Optional; final class NullnessCheckerDemo { private static <T extends Object> Optional<T> demo(Optional<Container<T>> maybeContainer) { return Optional.<T>empty().or(() -> maybeContainer.map(container -> container.element)); } class Container<T extends Object> { public final T element; Container(T element) { this.element = element; } } }
Removing any one of the generic, the container or the Optional make the test pass.
Optional
outputs:
NullnessCheckerDemo.java:7: error: [return] incompatible types in return. return Optional.<T>empty().or(() -> maybeContainer.map(container -> container.element)); ^ type of expression: T extends @Initialized @NonNull Object method return type: T extends @Initialized @Nullable Object 1 error
expectation: no error
The text was updated successfully, but these errors were encountered:
This was fixed with #979.
Sorry, something went wrong.
smillst
No branches or pull requests
I'm trying to pass a
@NonNull
value where the nullness checker expects@Nullable
. This seems safe to me but I get an error.commands:
checker-framework-3.19.0/checker/bin/javac -processor nullness NullnessCheckerDemo.java
inputs:
NullnessCheckerDemo.java
:Removing any one of the generic, the container or the
Optional
make the test pass.outputs:
expectation:
no error
The text was updated successfully, but these errors were encountered: