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/IterableViewLike.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/IterableViewLike.scala')
-rw-r--r-- | src/library/scala/collection/IterableViewLike.scala | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/library/scala/collection/IterableViewLike.scala b/src/library/scala/collection/IterableViewLike.scala index 668190f700..b84d90c51b 100644 --- a/src/library/scala/collection/IterableViewLike.scala +++ b/src/library/scala/collection/IterableViewLike.scala @@ -150,10 +150,10 @@ trait IterableViewLike[+A, sliding(size, 1) // we could inherit this, but that implies knowledge of the way the super class is implemented. override def dropRight(n: Int): This = - take(thisSeq.length - n) + take(thisSeq.length - math.max(n, 0)) override def takeRight(n: Int): This = - drop(thisSeq.length - n) + drop(thisSeq.length - math.max(n, 0)) override def stringPrefix = "IterableView" } |