ucr-riple / NullAwayAnnotator

A tool to help adapting code bases to NullAway type system.
MIT License
13 stars 6 forks source link

Add @NullUnmarked on constructors #133

Closed nimakarimipour closed 1 year ago

nimakarimipour commented 1 year ago

This PR fixes a bug which was causing annotator to only inject @NullUnmarked annotations on methods. This PR fixes this issue and enables Annotator to add @NullUnmarked annotation for errors enclosed by constructors.

nimakarimipour commented 1 year ago

@msridhar @lazaroclapp I noticed a problem in a followup PR for this PR and updated this one. Would you please take a look at the changes.

The plan for remaining error suppression is as below:

  1. Add @NullUnmarked on the containing method where the error is reported except for initialization errors.
  2. Add SuppressWarings("NullAway.Init") for initialization errors on the field not on the constructors.
  3. Add SuppressWarings("NullAway") for errors in the initializer expression for fields on the initialized field except for passing nullable as parameters.
  4. For passing nullable errors in the initializer expression for fields, annotate the invoked method as @NullUnmarked.
  5. Add NullUnmarked at the class level for errors in the static initialization blocks
  6. Add NullUnmarked at the class level if the error is still unresolved after step 1 to 4.

Prior to the changes I made recently, we were adding @NullUnmarked on the constructors for uninitialized fields. The latest changes also conforms to version 1.3.6-alpha-5.

nimakarimipour commented 1 year ago

@msridhar @lazaroclapp Please find the update test case here 5f25f1b66e08ea568e9e03f17a53fc79cbe39516. This unit test with this change would have been failed without changes in this PR.

nimakarimipour commented 1 year ago

@msridhar @lazaroclapp Thank you very much for the review. I will land this now. We can continue the discussion in #137