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

Dataflow and comparisons to true/false #3275

Closed
wmdietl opened this issue Apr 27, 2020 · 0 comments · Fixed by #3721
Closed

Dataflow and comparisons to true/false #3275

wmdietl opened this issue Apr 27, 2020 · 0 comments · Fixed by #3721

Comments

@wmdietl
Copy link
Member

wmdietl commented Apr 27, 2020

Found another interesting example:

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

class Bug {
  void foo(@Nullable Object obj) {
    if ((obj != null) == false) {
      // :: (dereference.of.nullable)
      obj.toString(); // BUG: no warning about this dereference
    }
  }
  
  void bar(@Nullable Object obj) {
    if (!(obj == null) == false) {
      // :: (dereference.of.nullable)
      obj.toString(); // BUG: no warning about this dereference
    }
  }
  
  void baz(@Nullable Object obj) {
    if ((obj == null) == true) {
      // :: (dereference.of.nullable)
      obj.toString();
    }
  }
}

Demo

Originally posted by @jdmota in #3267 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment