ucr-riple / NullAwayAnnotator

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

Add support for indexing of impacts of changes on fields on downstream dependencies #221

Closed nimakarimipour closed 9 months ago

nimakarimipour commented 10 months ago

This PR adds support for indexing impact of changes on fields on downstream dependencies. Prior to this PR, Annotator might make a field @Nullable that can trigger errors on downstream dependencies, with this PR, Annotator is aware of these impacts and if changes on fields, create an unresolvable error on downstream dependencies, the containing fix tree is rejected.

See example below:

On Target

public class Foo {

  public Object f0;

  public Object f1;

  public Object f2 = new Object();
}

On Dependency (Dep)

package test.depa;

import test.target.Foo;

public class Dep {

    public void directAccess(Foo foo){
         // making f0 will create an unresolvable error here.
         foo.f0.toString();
    }

    public void flowF1BackToF2(Foo foo) {
      // If f1 is annotated as @Nullable, the corresponding error on f2 can be resolved on target.
      foo.f2 = foo.f1;
    }
}

Prior to this PR, Annotator would have made f0 @Nullable even thought it causes an unresolvable error in Dep module. With this PR,