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 e620177d07f93c0af07e56afc93509e777accd9c
Author: Esko Toivonen <[email protected]>
AuthorDate: Tue Apr 6 17:59:44 2021 +0300

    GROOVY-9649: Fixed NumberRange.get not throwing at certain conditions
    
    With ranges like 0G<..<1G, the get method would erroneously return 1G
    instead of throwing an exception. This commit fixes that by directly
    incrementing the current value in the iterator instead of next() call.
---
 src/main/java/groovy/lang/NumberRange.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/groovy/lang/NumberRange.java 
b/src/main/java/groovy/lang/NumberRange.java
index 8a7c846..ece85c9 100644
--- a/src/main/java/groovy/lang/NumberRange.java
+++ b/src/main/java/groovy/lang/NumberRange.java
@@ -644,7 +644,7 @@ public class NumberRange extends AbstractList<Comparable> 
implements Range<Compa
                     // make the first fetch lazy too
                     next = isAscending ? range.getFrom() : range.getTo();
                     if (!range.inclusiveLeft) {
-                        next = next();
+                        next = isAscending ? increment(next, step) : 
decrement(next, step);
                     }
                 } else {
                     next = isAscending ? increment(next, step) : 
decrement(next, step);

Reply via email to