The source code of Range.Inclusive:
class Inclusive(start: Int, end: Int, step: Int) extends Range(start, end, step) {
override def 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, )
}
The line:
override protected val limit = end + Math.signum(step)
would lead to overflow when end equals Integer.MAX_VALUE or Integer.MIN_VALUE.
For example:
Welcome to Scala version 2.8.0.r19155-b20091020023404 (Java HotSpot(TM) Client VM, Java 1.6.0_16).
Type in expressions to have them evaluated.
Type :help for more information.
scala> val r = 0 to Integer.MAX_VALUE
r: scala.collection.immutable.Range.Inclusive with scala.collection.immutable.Range.ByOne = Range()
scala> r foreach println
scala>