Skip to content

Bug 195757 - Missing redundant null check in if condition through ternary operator #3990

@stephan-herrmann

Description

@stephan-herrmann

From https://bugs.eclipse.org/bugs/show_bug.cgi?id=195757

public class X {

  boolean test() {
    return true;
  }

  int foo() {
    if ((test() ? null : null) == null)
      return 1;
    return 0;
  }

  // more complex

  int bar() {
    String s = null;
    if ((test() ? s : null) == null)
      return 1;
    return 0;
  }
}

In both case, a "redundant null check" should be reported.

For initial discussion see bugzilla.

Metadata

Metadata

Assignees

Labels

nullIssues related to null pointer analysis

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions