diff options
author | Pavel Pavlov <pavel.e.pavlov@gmail.com> | 2014-02-08 19:34:26 +0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-02-24 21:32:38 -0800 |
commit | e0079c4274e418720c54b5e06e08adef023d7e79 (patch) | |
tree | b3641dab23182fa114b576b2c3841f03cffa5789 /test/files | |
parent | 7c709e122f7471353749525cff15602783fb348c (diff) | |
download | scala-e0079c4274e418720c54b5e06e08adef023d7e79.tar.gz scala-e0079c4274e418720c54b5e06e08adef023d7e79.tar.bz2 scala-e0079c4274e418720c54b5e06e08adef023d7e79.zip |
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
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/run/t4288.scala | 2 |
1 files changed, 1 insertions, 1 deletions
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) |