summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/SeqViewLike.scala
diff options
context:
space:
mode:
authorRex Kerr <ichoran@gmail.com>2014-12-06 14:18:24 -0800
committerRex Kerr <ichoran@gmail.com>2014-12-06 14:18:24 -0800
commit9f2083b88e003a3f2a641460244c44b0f1f06821 (patch)
tree3fc2ebabb001b7a016a3c78b1e4b2680c0b2f865 /src/library/scala/collection/SeqViewLike.scala
parent881048933667dc3e021d557e9f79e0850ac84712 (diff)
downloadscala-9f2083b88e003a3f2a641460244c44b0f1f06821.tar.gz
scala-9f2083b88e003a3f2a641460244c44b0f1f06821.tar.bz2
scala-9f2083b88e003a3f2a641460244c44b0f1f06821.zip
SI-8950 SeqView and StreamView allow indexing out of a slice
Added `idx >= 0` tests for `SeqViewLike#Sliced` `apply` and `mutable.IndexedSeqViewLike#Sliced` `unapply`. Now you get `IndexOutOfBoundsException`s as you should. No tests; this was found by collections-laws and will be tested by them. (Exact variants in bug report were tested in the REPL.)
Diffstat (limited to 'src/library/scala/collection/SeqViewLike.scala')
-rw-r--r--src/library/scala/collection/SeqViewLike.scala2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/library/scala/collection/SeqViewLike.scala b/src/library/scala/collection/SeqViewLike.scala
index ef6d2272cb..59e0e73e89 100644
--- a/src/library/scala/collection/SeqViewLike.scala
+++ b/src/library/scala/collection/SeqViewLike.scala
@@ -55,7 +55,7 @@ trait SeqViewLike[+A,
trait Sliced extends super.Sliced with Transformed[A] {
def length = iterator.size
def apply(idx: Int): A =
- if (idx + from < until) self.apply(idx + from)
+ if (idx >= 0 && idx + from < until) self.apply(idx + from)
else throw new IndexOutOfBoundsException(idx.toString)
override def foreach[U](f: A => U) = iterator foreach f