-
Notifications
You must be signed in to change notification settings - Fork 7
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
Treat @PolyNull
like @Nullable
.
#206
Conversation
This seems like something that we would have discussed previously, but I can't find any evidence of that. - Maybe the hope was that we'd soon implement _full_ support from scratch based on forthcoming JSpecify rules for `@PolyNull`? - Maybe the hope was that we'd be able to [make `@PolyNull` "imply" `@Nullable`](jspecify/jspecify#307 (comment)) soon? - Maybe the plan was to tell Checker Framework users to write [`@Nullable @PolyNull`](jspecify/jspecify#35)? - Maybe we once had a principle of recognizing only annotations that were "universally" recognized (or at least recognized by Kotlin), while `@PolyNull` is _not_? But if so, we moved away from that long ago. For now, it seems useful to at least recognize it. I could see us backtracking if we were to fall back to a policy of (at least optionally) recognizing _only_ JSpecify annotations or _only_ "universally" recognized annotations. But if we do so, that will involve a larger change than just reverting back this PR. (My immediate motivation is that J2CL is looking at `@PolyNull` support (@kevinoconnor7 FYI), and we've been trying to keep our lists of annotations in sync with theirs.) Hmm, and you know, only now that I'm writing this am I realizing that making `@PolyNull` imply `@Nullable` would not actually be sound, at least for the class definition of `@PolyNull`. I'll leave a note on jspecify/jspecify#79 and maybe in a doc or two that we have going about `@Implies`, assuming that I don't convince myself that I'm wrong by then.
Eh, nope, I already have to take that back :) I feel better about this PR. But to try to write down what I have been thinking since my last post: We already know that a checker that treats @PolyNull Object foo(@PolyNull Object o) {
return null; // should be an error but is actually allowed
} What had caught my attention was a more elaborate case that involved generics: @NullMarked
class Bar<T extends @Nullable Object> {
@PolyNull T foo(@PolyNull T t) {
...
}
}
Bar<@Nullable String> bar;
bar.foo(...); In that case, I was envisioning... I'm not entirely sure what, but it was going to be related to a point that I've already harped on before, which is that the existing In short, I don't think my new example fundamentally different from the simple, known example at the beginning of this post. It is still possible that there's something interesting to be said about other generic cases, such as with a type like So if there is any takeaway here, it's that treating |
@wmdietl mentioned today that we could implement My overall thinking is probably that I'd feel best with a resolution for jspecify/jspecify#79 before taking any steps here: We might not want to encourage further If the J2CL folks do end up landing support for |
This seems like something that we would have discussed previously, but I can't find any evidence of that.
@PolyNull
?@PolyNull
"imply"@Nullable
soon?@Nullable @PolyNull
?@PolyNull
is not? But if so, we moved away from that long ago.For now, it seems useful to at least recognize it. I could see us backtracking if we were to fall back to a policy of (at least optionally) recognizing only JSpecify annotations or only "universally" recognized annotations. But if we do so, that will involve a larger change than just reverting back this PR.
(My immediate motivation is that J2CL is looking at
@PolyNull
support (@kevinoconnor7 FYI), and we've been trying to keep our lists of annotations in sync with theirs.)Hmm, and you know, only now that I'm writing this am I realizing that making
@PolyNull
imply@Nullable
would not actually be sound, at least for the class definition of@PolyNull
. I'll leave a note on jspecify/jspecify#79 and maybe in a doc or two that we have going about@Implies
, assuming that I don't convince myself that I'm wrong by then. If I'm right, then it would actually make conceptual sense to not merge this PR, either....