summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/collection/immutable/GenericRange.scala1
-rw-r--r--src/library/scala/collection/immutable/Range.scala3
2 files changed, 4 insertions, 0 deletions
diff --git a/src/library/scala/collection/immutable/GenericRange.scala b/src/library/scala/collection/immutable/GenericRange.scala
index 886895215b..8b605f1c58 100644
--- a/src/library/scala/collection/immutable/GenericRange.scala
+++ b/src/library/scala/collection/immutable/GenericRange.scala
@@ -53,6 +53,7 @@ extends VectorView[T, collection.immutable.Vector[T]]
require(genericLength <= fromInt(Math.MAX_INT), "Implementation restricts ranges to Math.MAX_INT elements.")
// By adjusting end based on isInclusive, we can treat all ranges as exclusive.
+ // [Martin] !!! trueEnd is false, see Range#limit
private lazy val trueEnd: T = if (isInclusive) end + step else end
protected def underlying = collection.immutable.Vector.empty[T]
diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala
index 37b34d9028..b896d19231 100644
--- a/src/library/scala/collection/immutable/Range.scala
+++ b/src/library/scala/collection/immutable/Range.scala
@@ -36,6 +36,8 @@ class Range(val start: Int, val end: Int, val step: Int) extends Vector[Int] {
*/
def by(step: Int): Range = copy(start, end, step)
+ def isInclusive = false
+
protected def limit = end
override def foreach[U](f: Int => U) {
@@ -129,6 +131,7 @@ object Range {
private val MAX_PRINT = 512 // some arbitrary value
class Inclusive(start: Int, end: Int, step: Int) extends Range(start, end, step) {
+ override isInclusive = true
override protected val limit = end + Math.signum(step)
override protected def copy(start: Int, end: Int, step: Int): Range = new Inclusive(start, end, step)
}