diff options
author | Rui Gonçalves <ruippeixotog@gmail.com> | 2014-05-12 00:29:44 +0100 |
---|---|---|
committer | Rui Gonçalves <ruippeixotog@gmail.com> | 2014-05-12 00:29:44 +0100 |
commit | 7f08e00a3aa0f59314767313977d9f2899a80cd9 (patch) | |
tree | bbf7de6e28ca76648b72c31a5911c255f8b9eab6 /src/library | |
parent | 3f28bbed6d1c2d49201da700907aae460f15cd4d (diff) | |
download | scala-7f08e00a3aa0f59314767313977d9f2899a80cd9.tar.gz scala-7f08e00a3aa0f59314767313977d9f2899a80cd9.tar.bz2 scala-7f08e00a3aa0f59314767313977d9f2899a80cd9.zip |
SI-8553 WrappedArray throws exception on lastIndexWhere when index out of range
Adds a check in `IndexedSeqOptimized#lastIndexWhere(A => Boolean, Int)`
to begin searching in the end of the collection if `end` is greater than
the collection's length.
Discussed in
https://groups.google.com/d/topic/scala-internals/-MacXivbY0Q/discussion.
Diffstat (limited to 'src/library')
-rwxr-xr-x | src/library/scala/collection/IndexedSeqOptimized.scala | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/library/scala/collection/IndexedSeqOptimized.scala b/src/library/scala/collection/IndexedSeqOptimized.scala index ade04e4de8..42cb37aa24 100755 --- a/src/library/scala/collection/IndexedSeqOptimized.scala +++ b/src/library/scala/collection/IndexedSeqOptimized.scala @@ -206,7 +206,7 @@ trait IndexedSeqOptimized[+A, +Repr] extends Any with IndexedSeqLike[A, Repr] { override /*SeqLike*/ def lastIndexWhere(p: A => Boolean, end: Int): Int = { - var i = end + var i = math.min(end, length - 1) while (i >= 0 && !p(this(i))) i -= 1 i } |