-
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
Add an option to support correct positioning of type use annotations on arrays, even outside JSpecify mode #1007
Comments
OK apparently after looking around I think it is because I don't have JSpecifyMode turned on. So I guess we can close this bug (I did find other issues with generics but it appears those are a work in progress). |
Hi @agentgt thanks for the report. I think there is a real issue here that we should fix. NullAway has traditionally not had support for "correct" placement of type use annotations like those from JSpecify or Checker Framework. As you noticed, our full support for JSpecify checking (under the |
@msridhar I wonder if you can just look at the annotation to see if it is That is I assume the original behavior is because NullAway was supporting the defunct JSR Anyway thanks for the reply. I'll try to help in the future by using NullAway on my various projects in conjunction w/ checker + eclipse! |
@agentgt hrm, the issue is backwards compatibility. It's possible we have users who were using CF type use nullability annotations on arrays in the "wrong" place before, and it worked as they expected with NullAway. I'm not sure we want to introduce a bunch of new errors in their code when they upgrade. On the other hand, maybe it would be good to start getting people more used to the new locations? The problem with the flag approach is that folks might adopt JSpecify annotations but in the wrong way if they don't pass the flag. @lazaroclapp @yuxincs thoughts here? |
Another thought here is we could add an opt-out flag rather than opt-in. So, by default, we assume type use annotations should be in the right place, but you can pass the flag to go back to "legacy" mode for backward compatibility. And eventually we remove that flag. I think I like this idea best. |
…e of JSpecify mode (#1010) Currently, outside of JSpecify, both top-level and element annotations are treated the same, i.e., considered as top-level annotations. This changes the default behavior by ignoring annotations on elements and adds a flag to revert back to legacy behavior. **Example:** ``` @nullable Object[] foo1 = null; Object @nullable[] foo2 = null; ``` **Current Behavior:** Both assignments are fine **New Behavior:** The first assignment raises an error since annotations on elements are ignored altogether and **_NOT_** treated as top-level annotations. Fixes #1007 --------- Co-authored-by: Manu Sridharan <msridhar@gmail.com>
@agentgt FWIW this should be fixed now. I think the Eclipse |
@msridhar I'll let you know next week. Thank you for all the work! |
I normally use Checkerframework and Eclipse for null checking so apologies on my ignorance and or if this is a known issue.
I have field like:
protected @Nullable String[] kvs;
https://github.com/jstachio/rainbowgum/blob/31c71243eef1661513516938005a064663930bf2/core/src/main/java/io/jstach/rainbowgum/KeyValues.java#L378
I get a compiler error here
https://github.com/jstachio/rainbowgum/blob/31c71243eef1661513516938005a064663930bf2/core/src/main/java/io/jstach/rainbowgum/KeyValues.java#L396
rainbowgum/core/src/main/java/io/jstach/rainbowgum/KeyValues.java:[396,26] [NullAway] dereferenced expression kvs is @Nullable
I'm using the Eclipse TYPE_USE annotations and mostly following JSpecify. It appears that Nullaway thinks that kvs is nullable and not the elements. Perhaps if I switch to the JSpecify annotations it will know that it means the elements or not?
It works with Eclipse null analysis and Checkerframework.
The text was updated successfully, but these errors were encountered: