summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2014-02-14 13:23:44 -0800
committerAdriaan Moors <adriaan.moors@typesafe.com>2014-02-14 13:23:44 -0800
commitd62ceb88278bbe8317e8dcce6fb8515cae64e2b1 (patch)
tree9ebf30b69000bd659452a79fc1d36e2876455dfc /src/library
parentd227a89363886635969f4a7725303c6b65b0914b (diff)
parentd3a302b022adc5eaeb1fcbdffaffd5fd438726e0 (diff)
downloadscala-d62ceb88278bbe8317e8dcce6fb8515cae64e2b1.tar.gz
scala-d62ceb88278bbe8317e8dcce6fb8515cae64e2b1.tar.bz2
scala-d62ceb88278bbe8317e8dcce6fb8515cae64e2b1.zip
Merge pull request #3530 from Ichoran/issue/6632
SI-6632 ListBuffer's updated accepts negative positions
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/collection/SeqLike.scala5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala
index 960c277f67..fdfb1f2efc 100644
--- a/src/library/scala/collection/SeqLike.scala
+++ b/src/library/scala/collection/SeqLike.scala
@@ -509,11 +509,14 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
}
def updated[B >: A, That](index: Int, elem: B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
+ if (index < 0) throw new IndexOutOfBoundsException(index.toString)
val b = bf(repr)
val (prefix, rest) = this.splitAt(index)
+ val restColl = toCollection(rest)
+ if (restColl.isEmpty) throw new IndexOutOfBoundsException(index.toString)
b ++= toCollection(prefix)
b += elem
- b ++= toCollection(rest).view.tail
+ b ++= restColl.view.tail
b.result()
}