Skip to content
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

@RequiresNonNull does not appear to be honored inside anonymous class #553

Closed
elcelista opened this issue Jan 8, 2016 · 0 comments · Fixed by #3660
Closed

@RequiresNonNull does not appear to be honored inside anonymous class #553

elcelista opened this issue Jan 8, 2016 · 0 comments · Fixed by #3660

Comments

@elcelista
Copy link

I would expect the following to check successfully:

MonotonicNonNullFieldTest.java

import org.checkerframework.checker.nullness.qual.*;

public class MonotonicNonNullFieldTest {
  class Data {
    @MonotonicNonNull Object field;
  }

  void method(Object object) {
  }

  @RequiresNonNull("#1.field")
  void test(final Data data) {
    method(data.field);  // checks OK

    Runnable callback = new Runnable() {
      public void run() {
        method(data.field);  // fails check
      }
    };
  }
}

However I get the following error:

$ java -jar checker.jar -processor org.checkerframework.checker.nullness.NullnessChecker -version MonotonicNonNullFieldTest.java
javac 1.8.0-jsr308-1.9.10
MonotonicNonNullFieldTest.java:17: error: [argument.type.incompatible] incompatible types in argument.
        method(data.field);  // fails check
                   ^
  found   : @Initialized @MonotonicNonNull Object
  required: @Initialized @NonNull Object
1 error

I saw #294 and #266, which appear to be describing a similar issue, but this issues seems different because it doesn't appear to depend on flow analysis.

@smillst smillst modified the milestone: Medium Feb 10, 2016
smillst added a commit that referenced this issue Sep 14, 2020
This issue has been fixed. Closes #553.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants