Skip to content

Commit

Permalink
Collapse constitutionals in SimplifyBooleanExpression (#421)
Browse files Browse the repository at this point in the history
* form

* shouldSimplifyEqualsOn

* Update src/main/java/org/openrewrite/staticanalysis/SimplifyBooleanExpression.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: Vincent Potucek <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 27, 2024
1 parent 34d6589 commit 383358b
Showing 1 changed file with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,8 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
// e.g. `X?.fun() == true` is not equivalent to `X?.fun()`
@Override
protected boolean shouldSimplifyEqualsOn(@Nullable J j) {
if (j == null) {
return true;
}

if (j instanceof J.MethodInvocation) {
J.MethodInvocation m = (J.MethodInvocation) j;
return !m.getMarkers().findFirst(IsNullSafe.class).isPresent();
}

return true;
return !(j instanceof J.MethodInvocation) ||
!j.getMarkers().findFirst(IsNullSafe.class).isPresent();
}
};
}
Expand Down

0 comments on commit 383358b

Please sign in to comment.