From e0079c4274e418720c54b5e06e08adef023d7e79 Mon Sep 17 00:00:00 2001 From: Pavel Pavlov Date: Sat, 8 Feb 2014 19:34:26 +0700 Subject: SI-8251 deprecate `ListBuffer::readOnly` This is the first step towards fixing the unexpected behavior of `ListBuffer`. Many of `ListBuffer`'s operations are forwarded to the underlying `List`, essentially leaking that abstraction to clients that call e.g., `toIterable`. When the buffer changes, the `Iterable` obtained through `toIterable` will reflect that change. To avoid this exposure, call `toList` to obtain an immutable copy. See also: https://groups.google.com/d/msg/scala-internals/g_-gIWgB8Os/kWazrALbLKEJ https://gist.github.com/paulp/9081797 --- test/files/run/t4288.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/files/run/t4288.scala') diff --git a/test/files/run/t4288.scala b/test/files/run/t4288.scala index 4e7b366f60..23319d1c27 100644 --- a/test/files/run/t4288.scala +++ b/test/files/run/t4288.scala @@ -1,6 +1,6 @@ object Test { def f1 = scala.collection.mutable.ListBuffer(1 to 9: _*).slice(-5, -1) - def f2 = scala.collection.mutable.ListBuffer(1 to 9: _*).readOnly.slice(-5, -1) + def f2 = List(1 to 9: _*).slice(-5, -1) def f3 = Vector(1 to 9: _*).slice(-5, -1) def f4 = Traversable(1 to 9: _*).slice(-5, -1) def f5 = (1 to 9).toArray.slice(-5, -1) -- cgit v1.2.3