summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/collection/SeqViewLike.scala2
-rw-r--r--src/library/scala/collection/mutable/IndexedSeqView.scala2
2 files changed, 2 insertions, 2 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
diff --git a/src/library/scala/collection/mutable/IndexedSeqView.scala b/src/library/scala/collection/mutable/IndexedSeqView.scala
index 31a4749960..7acdeeff18 100644
--- a/src/library/scala/collection/mutable/IndexedSeqView.scala
+++ b/src/library/scala/collection/mutable/IndexedSeqView.scala
@@ -50,7 +50,7 @@ self =>
trait Sliced extends super.Sliced with Transformed[A] {
override def length = endpoints.width
def update(idx: Int, elem: A) =
- if (idx + from < until) self.update(idx + from, elem)
+ if (idx >= 0 && idx + from < until) self.update(idx + from, elem)
else throw new IndexOutOfBoundsException(idx.toString)
}