Skip to content

Commit

Permalink
Avoid "Comparison method violates its general contract!" exception
Browse files Browse the repository at this point in the history
  • Loading branch information
axkr committed Sep 10, 2023
1 parent 79dcb7a commit b27a1a6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ public int compareTo(IExpr expr) {
return c;
}
IExpr im = expr.im();
return !im.isPositive() ? 1 : -1;
return im.isPositive() ? -1 : im.isNegative() ? 1 : IExpr.compareHierarchy(this, expr);
}
return IExpr.compareHierarchy(this, expr);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public int compareTo(final IExpr expr) {
return c;
}
IExpr im = expr.im();
return !im.isPositive() ? 1 : -1;
return im.isPositive() ? -1 : im.isNegative() ? 1 : IExpr.compareHierarchy(this, expr);
}
return IExpr.compareHierarchy(this, expr);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ public int compareTo(final IExpr expr) {
if (c != 0) {
return c;
}
IExpr im = expr.im();
return im.isPositive() ? -1 : im.isNegative() ? 1 : IExpr.compareHierarchy(this, expr);
}
return IExpr.compareHierarchy(this, expr);
}
Expand Down

0 comments on commit b27a1a6

Please sign in to comment.