SI-8251 deprecate `ListBuffer::readOnly` #3582

Merged
merged 1 commit into from Feb 25, 2014

Conversation

Projects
None yet
4 participants
@adriaanm
Member

adriaanm commented Feb 25, 2014

This is a minimal version of #3489, which only deprecates 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

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

@adriaanm adriaanm added the tested label Feb 25, 2014

@Ichoran

This comment has been minimized.

Show comment
Hide comment
@Ichoran

Ichoran Feb 25, 2014

Contributor

LGTM.

Contributor

Ichoran commented Feb 25, 2014

LGTM.

@adriaanm adriaanm added the reviewed label Feb 25, 2014

gkossakowski added a commit that referenced this pull request Feb 25, 2014

Merge pull request #3582 from adriaanm/t8251
SI-8251 deprecate `ListBuffer::readOnly`

@gkossakowski gkossakowski merged commit a06fe78 into scala:master Feb 25, 2014

1 check passed

default pr-scala Took 56 min.
Details

@adriaanm adriaanm deleted the adriaanm:t8251 branch Mar 10, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment