This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 8e54d6c8fc3b5bb2b6ee10c5908776b1f05e3af3
Author: Eerik Voimanen <[email protected]>
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

Reply via email to