From 3adaa37cd2fc40deeb58ce9da9015f329d9c254e Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 28 May 2011 23:28:11 +0000 Subject: Yikes, prependToList was violating List immutab... Yikes, prependToList was violating List immutability. Closes #4656, no review. --- src/library/scala/collection/mutable/ListBuffer.scala | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala index 6a75108dfb..f1271627c1 100644 --- a/src/library/scala/collection/mutable/ListBuffer.scala +++ b/src/library/scala/collection/mutable/ListBuffer.scala @@ -245,9 +245,14 @@ final class ListBuffer[A] * * @param xs the list to which elements are prepended */ - def prependToList(xs: List[A]): List[A] = + def prependToList(xs: List[A]): List[A] = { if (start.isEmpty) xs - else { last0.tl = xs; toList } + else { + if (exported) copy() + last0.tl = xs + toList + } + } // Overrides of methods in Buffer -- cgit v1.2.3