Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Conversation

@allanrenucci
Copy link
Contributor

No description provided.

odersky added 6 commits March 22, 2018 18:58
The specializations were all unsound since they typically returned WithFilter of
a collection {Iterable/Map/Set} where a mutable or immutable collection was required.
We need to either drop them or come up with a sound design.
There were three methods specialized in ArrayDeque to return some structure
of ArrayDeques instead of the underlying collection type. These were inherited
without overridng by Queue and Stack. This means the contract is broken: The type
says that e.g. sliding returns an Iterator[Queue] but in reality it returns
an Iterator[ArrayDeque].
@sjrd
Copy link
Member

sjrd commented Mar 23, 2018

I'd like to point out that those protected[this] members are (likely) unsound. AFAICT, they're very similar to thisCollection and toCollection in the old collections, which do cause ClassCastExceptions if they're not systematically overridden by subclasses.

For example, see the old issue scala-js/scala-js#843 and its fix https://github.com/scala-js/scala-js/pull/851/files.

@odersky
Copy link
Contributor

odersky commented Mar 23, 2018

@sjrd Yes, that's my sentiment as well. It needs to be documented thoroughly.

.travis.yml Outdated
script:
- sbt ++2.12.4 memoryBenchmark/compile test ++2.13.0-M2 timeBenchmark/compile test ++0.7.0-RC1 test
- sbt ++2.12.4 memoryBenchmark/compile test ++2.13.0-M2 timeBenchmark/compile test
- sbt ++0.8.0-bin-20180323-5be1360-NIGHTLY test junit/test:compile
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The collections-contrib still fail to compile under Dotty due to an issue with WithFilter. Running the tests in the junit project fails with Dotty. I'll be looking into it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@julienrf I you managed to fix the collections-contrib with Dotty, you can add them to the CI tests

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is still a compiler crash when compiling MapDecoratorTest.scala, but at least collections-contribJVM/compile works with Dotty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks! I'll look into the crash

It is still built on top of the unsound `protected[this] type IterableCC`
thing, though.
@julienrf
Copy link
Contributor

I’ve just pushed a commit to get withFilter working. It is implemented on top of the unsound IterableCC-like types, but I think if we want to get it right we’d really have to have one WithFilter implementation per subclass of Iterable.

@julienrf
Copy link
Contributor

I’ve also fixed ArrayDeque so that Stack and Queue can benefit from its overrides.

@julienrf
Copy link
Contributor

julienrf commented Mar 26, 2018

Some junit/tests are still failing with Dotty. They seem to be related with serialization, synchronization and garbage collection.

@julienrf julienrf added the port to scala/scala PRs that should be ported to the scala/scala repo after we moved the collections there label Mar 26, 2018
julienrf added a commit to julienrf/scala that referenced this pull request Apr 10, 2018
Insert explicit @uncheckedVariance annotations even for private[this]
or protected[this] members.

This commit is a port of scala/collection-strawman#521
@julienrf
Copy link
Contributor

julienrf commented Apr 10, 2018

This PR has been ported to scala/scala but I leave it open here because we will eventually have to also port the part that touches the collections-contrib project.

scala/scala#6508

julienrf added a commit to julienrf/scala that referenced this pull request Apr 11, 2018
Insert explicit @uncheckedVariance annotations even for private[this]
or protected[this] members.

This commit is a port of scala/collection-strawman#521
julienrf added a commit to julienrf/collection-strawman that referenced this pull request Apr 18, 2018
Subset of scala#521 containing only changes applied
to the collections-contrib module. The other changes have already
been ported to scala/scala#6508.
@julienrf
Copy link
Contributor

Superseded by #561 and scala/scala#6508

@julienrf julienrf closed this Apr 18, 2018
julienrf added a commit to julienrf/scala-collection-contrib that referenced this pull request Apr 19, 2018
Subset of scala/collection-strawman#521 containing only changes applied
to the collections-contrib module. The other changes have already
been ported to scala/scala#6508.
julienrf added a commit to julienrf/scala that referenced this pull request Apr 25, 2018
…riance` annotations.

This commit is a port of scala/collection-strawman#521

Let’s assume that our code is unsound by not relying on the
`protected[this]` escape hatch that disables variance checking.

Instead, properly insert `@uncheckedVariance` annotations to see
where we are doing bad things.

On a positive note, this also encourages us to better document the
restrictions of such unsound members.

Add tests showing that `reverse` behaves correctly on ArrayDeque subclasses.

Fixes scala/collection-strawman#505
Fixes scala/collection-strawman#547
julienrf added a commit to julienrf/scala that referenced this pull request Apr 25, 2018
…riance` annotations.

This commit is a port of scala/collection-strawman#521

Let’s assume that our code is unsound by not relying on the
`protected[this]` escape hatch that disables variance checking.

Instead, properly insert `@uncheckedVariance` annotations to see
where we are doing bad things.

On a positive note, this also encourages us to better document the
restrictions of such unsound members.

Add tests showing that `reverse` behaves correctly on ArrayDeque subclasses.

Fixes scala/collection-strawman#505
Fixes scala/collection-strawman#547
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

port to scala/scala PRs that should be ported to the scala/scala repo after we moved the collections there

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants