-
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
[0.10.6] @Nullable ignored and warns as non-null field #705
Comments
Um, that's really weird. We are definitely not seeing that behavior in general (i.e. for all p.s. Trying to get a repro going right now, but so far, the following produces no warnings:
|
Sorry, I don't have a repro but I pushed the commit to a dev branch if you want to run the build.
|
Well, something really weird is going on here... does your gradle build set a specific java version? If not, what do you get out of cc: @msridhar |
Yes, the build uses Java 11 via a toolchain. Maybe due to the remote build cache it was not run locally? you can try
|
Update: That did the trick. Also, got a repro now:
And the first commit in NullAway it fails on (after #702). Looking into the cause. |
Got a candidate fix: #706 Issue is in how we detect the locations of type use annotations (i.e. how we figure out we are looking at For the error to manifest, it needs to involve a field of an inner type where the outer type is implicit, and a type use version of That suggests one, admittedly annoying, alternative workaround:
(Alternatively, suppressing NullAway.Init or remaining on 0.10.5 for a couple days are good options too!) Realistically, we probably won't be able to cut NullAway 0.10.7 until after the new year, but once we do, it should include the fix above :) |
thanks for the quick fix! I'll remove the suppression whenever the next release lands. |
This resolves #705 by broadening our slightly overzealous filtering from #702. We still want to filter type use annotations out when they happen on wildcards or type parameters. However, we can handle annotations on inner types (i.e. `Foo.@nullable Bar`). More importantly, these inner types appear implicitly in natural code involving inner classes, such as: ``` class Bar { @nullable Foo foo; // <- this is, implicitly Bar.@nullable Foo !! class Foo { } } ``` Not handling this case leads to confusing an unintuitive errors where a `@Nullable` annotation with a type use location will seemingly stop working for certain fields at random, if those fields are of an inner type. Additionally, as part of this fix, we restore the handling of type use annotations at the start of an array type as meaning the array object itself is `@Nullable` (i.e. `@Nullable Foo[] arr`, in addition to the correct type use form `Foo @nullable[] arr`). This is technically incorrect, but prohibiting it would break backwards compatibility with older versions of NullAway and surprise users, specially those switching from declaration annotations to type use annotations. See #708 for a full discussion of the tradeoffs and the path forward towards the proper semantics for type use annotations. Co-authored-by: Manu Sridharan <[email protected]>
Update: NullAway 0.10.7 is now out with the #706 as the only change. I just tested updating the dep in the repro given above and it all builds successfully, except for some EP warnings about This is a temporary fix, pending some more principled handling of type use annotations that matches JSpecify semantics (see #708), but it should resolve this issue. |
This is easily resolved by adding the suppression, but it appears to be a regression unless I am doing something wrong?
The text was updated successfully, but these errors were encountered: