preserve immutable collections in to(Target) conversions#495
Merged
lrytz merged 3 commits intoscala:mainfrom Nov 8, 2021
Merged
preserve immutable collections in to(Target) conversions#495lrytz merged 3 commits intoscala:mainfrom
to(Target) conversions#495lrytz merged 3 commits intoscala:mainfrom
Conversation
0af7d33 to
0b2fc40
Compare
lrytz
commented
Oct 29, 2021
| sharedSourceDir / "scala-2.11_2.12" | ||
| } | ||
| }, | ||
| Test / unmanagedSourceDirectories += { |
Member
Author
There was a problem hiding this comment.
copy paste from above, not sure how to factor things out in sbt
Member
Author
|
cc @martijnhoekstra, since you originally wrote |
Member
|
this might interest @scala/collections |
johnynek
reviewed
Oct 30, 2021
compat/src/main/scala-2.11_2.12/scala/collection/compat/CompatImpl.scala
Outdated
Show resolved
Hide resolved
compat/src/main/scala-2.11_2.12/scala/collection/compat/CompatImpl.scala
Outdated
Show resolved
Hide resolved
NthPortal
reviewed
Nov 1, 2021
compat/src/main/scala-2.11_2.12/scala/collection/compat/CompatImpl.scala
Show resolved
Hide resolved
NthPortal
reviewed
Nov 1, 2021
Contributor
NthPortal
left a comment
There was a problem hiding this comment.
initial review is that it looks correct. if I get more energy, hopefully I can do a more thorough review.
I did not review of the sbt changes, as I'm less confident in my ability to refactor sbt configs than in yours
Member
Author
|
Thank you @NthPortal! |
johnynek
approved these changes
Nov 1, 2021
retronym
approved these changes
Nov 4, 2021
Member
|
@lrytz can you fill in the PR description? |
to(Target) conversions
Member
Author
|
👍 done |
Contributor
|
oh, this is already released, awesome! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In Scala 2.13,
collection.to(Target)conversions return thecollectionobject unchanged if it is immutable and is already a subtype of theTargettype.This PR brings the same behavior to Scala 2.12 when using scala-collection-compat.
The 2.12 codebase is unchanged, so a
to[Target]conversion may still create unnecessary copies.Remaining differences between 2.12 and 2.13:
static types: 2.12's
tois defined asdef to[Col[_]](implicit cbf: CanBuildFrom[Nothing, A, Col[A]]): Col[A], soto(Map)has static typeIterable[(K, V)], notMap[K, V]lazy maps:
mapValuesreturns a lazy map that's a subtype ofimmutable.Map, so