diff options
author | Rui Gonçalves <ruippeixotog@gmail.com> | 2014-11-11 01:45:22 +0000 |
---|---|---|
committer | Rui Gonçalves <ruippeixotog@gmail.com> | 2014-11-11 01:45:22 +0000 |
commit | 729e7a91f43c327a9514fa53045842eb3e7db49b (patch) | |
tree | fa095f4c45f93cac76c4271a90efafbb2d3e81fb /src/library/scala/collection/IndexedSeqOptimized.scala | |
parent | 0e8c6dac596279414dce576aa9f88289aa582fcc (diff) | |
download | scala-729e7a91f43c327a9514fa53045842eb3e7db49b.tar.gz scala-729e7a91f43c327a9514fa53045842eb3e7db49b.tar.bz2 scala-729e7a91f43c327a9514fa53045842eb3e7db49b.zip |
SI-8932 Fix dropRight/takeRight implementations
I looked up at all the overrides of `IterableLike#takeRight` and
`IterableLike#dropRight` and replaced usages of its argument `n` with
`math.max(n, 0)` every time it was being used in an index subtraction.
Fixes [SI-8932](https://issues.scala-lang.org/browse/SI-8932).
Diffstat (limited to 'src/library/scala/collection/IndexedSeqOptimized.scala')
-rwxr-xr-x | src/library/scala/collection/IndexedSeqOptimized.scala | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/library/scala/collection/IndexedSeqOptimized.scala b/src/library/scala/collection/IndexedSeqOptimized.scala index 42cb37aa24..a7e06b4d1a 100755 --- a/src/library/scala/collection/IndexedSeqOptimized.scala +++ b/src/library/scala/collection/IndexedSeqOptimized.scala @@ -141,10 +141,10 @@ trait IndexedSeqOptimized[+A, +Repr] extends Any with IndexedSeqLike[A, Repr] { def drop(n: Int): Repr = slice(n, length) override /*IterableLike*/ - def takeRight(n: Int): Repr = slice(length - n, length) + def takeRight(n: Int): Repr = slice(length - math.max(n, 0), length) override /*IterableLike*/ - def dropRight(n: Int): Repr = slice(0, length - n) + def dropRight(n: Int): Repr = slice(0, length - math.max(n, 0)) override /*TraversableLike*/ def splitAt(n: Int): (Repr, Repr) = (take(n), drop(n)) |