-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
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
ignoring generic Nullable on Supplier #947
Comments
@xenoterracide this is due to the fact that NullAway's support for generic types is still a WIP. We're slowly approaching something usable but I'd say it's not quite there yet. If you want to test it out, you can pass the flag |
@msridhar Yes I am working on adding support for pulling in |
Try is from vavr, maybe I don't understand how this is supposed to work? but I feel like this should compile. private final Supplier<Optional<Git>> git;
Try<@Nullable String> describe() {
return this.git.get()
.map(g -> Try.of(() -> g.describe().setMatch(VERSION_GLOB).setTags(true)))
.orElseGet(NoGitDirException::failure)
.mapTry(DescribeCommand::call)
.recover(NoGitDirException.class, e -> null);
} /home/xeno/IdeaProjects/gradle-semver/src/main/java/com/xenoterracide/gradle/semver/GitMetadataExtension.java:44: error: [NullAway] Generic type parameter cannot be @Nullable, as type variable T of type io.vavr.control.Try does not have a @Nullable upper bound
Try<@Nullable String> describe() {
^
(see http://t.uber.com/nullaway )
/home/xeno/IdeaProjects/gradle-semver/src/main/java/com/xenoterracide/gradle/semver/GitMetadataExtension.java:49: error: [NullAway] Cannot return expression of type Try<String> from method with return type Try<@Nullable String> due to mismatched nullability of type parameters
.recover(NoGitDirException.class, e -> null);
^
(see http://t.uber.com/nullaway ) |
I think you're just running into shortcomings / missing features of our implementation. Can you point me at the source for the |
But bottom line our support for JSpecify is not ready for real-world use yet. The only open implementation I know of that would probably work is https://github.com/jspecify/jspecify-reference-checker. But these test cases are really valuable for prioritizing our work. |
It's vavr ... https://github.com/vavr-io/vavr |
probably another, again vavr, .map(d -> Iterables.get(Splitter.on('-').split(d), 1)) |
Ok, so there are multiple things going on here. First, let's assume you've made https://github.com/vavr-io/vavr/blob/master/src/main/java/io/vavr/control/Try.java#L64 Notice the declaration is I'm guessing, however, that |
I did not, because it is not. I Don't do that for libraries that are either, am I supposed to? I've only been doing it for my own. I don't do it on Spring for example. I'm not sure how Nullaway interacts with NonNullApi and NonNullFields... tbh. note: I'm not aware of any libraries that actually use jspecify's annotations. I know that spring has seemed to decide that jspecify will not be meeting its needs anytime soon. As far as Try goes, it's |
So for libraries outside of annotated packages, like vavr, to me the most sensible JSpecify behavior is to treat them as |
That matches my expectations I'm just not sure how detection of annotated libraries works. |
Our plan for detection of annotated libraries is as follows:
If you have any feedback on this please let us know |
If there aren't module/package annotations we can set a library to marked ourselves? presumably like I do my own. Is that still necessary if I |
Yes, by just using the annotated packages option.
I'm not sure honestly if we added code yet to look up the |
maybe I don't understand how the generic is supposed to work...
Git
here is fromjgit
but I don't think that's relevant.get
can return null, and so this should produce an error. In fact 2 errors, firstly the field doesn't match the constructor signature, but even if you add the nullable generic to the field it still doesn't error.note: I have tested this in my build, but not independently yet. So if it fails to do so outside... I can try to find something better.
The text was updated successfully, but these errors were encountered: