You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2021/04/12 06:04:29 UTC
[groovy] 23/26: GROOVY-9649: Fix bug in IntRange.equals
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch groovy9649
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 180cf92facf32b6e66d58f61fabc04388a8e5d6c
Author: Eerik Voimanen <ee...@tuni.fi>
AuthorDate: Fri Apr 9 15:53:19 2021 +0300
GROOVY-9649: Fix bug in IntRange.equals
---
src/main/java/groovy/lang/IntRange.java | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/src/main/java/groovy/lang/IntRange.java b/src/main/java/groovy/lang/IntRange.java
index a605a4b..cb5d172 100644
--- a/src/main/java/groovy/lang/IntRange.java
+++ b/src/main/java/groovy/lang/IntRange.java
@@ -298,11 +298,10 @@ public class IntRange extends AbstractList<Integer> implements Range<Integer>, S
*/
public boolean equals(IntRange that) {
return that != null && from == that.from && to == that.to && (
- (inclusiveRight == null && inclusiveLeft == null && reverse == that.reverse)
- || (
- (inclusiveLeft == null || Objects.equals(inclusiveLeft, that.inclusiveLeft))
- && (inclusiveRight == null || Objects.equals(inclusiveRight, that.inclusiveRight))
- )
+ // If inclusiveRight is null, then inclusive left is also null (see constructor)
+ (inclusiveRight == null) ? reverse == that.reverse:
+ (Objects.equals(inclusiveLeft, that.inclusiveLeft)
+ && Objects.equals(inclusiveRight, that.inclusiveRight))
);
}
@@ -417,8 +416,7 @@ public class IntRange extends AbstractList<Integer> implements Range<Integer>, S
if (inclusiveRight == null && inclusiveLeft == null) {
return reverse ? "" + to + ".." + from : "" + from + ".." + to;
}
- return "" + from + ((inclusiveLeft != null && inclusiveLeft) ? "" : "<") + ".."
- + ((inclusiveRight != null && inclusiveRight) ? "" : "<") + to;
+ return "" + from + (inclusiveLeft ? "" : "<") + ".." + (inclusiveRight ? "" : "<") + to;
}
@Override