-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
preserve immutable collections in to(Target)
conversions
#495
Conversation
0af7d33
to
0b2fc40
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review by @retronym
@@ -72,19 +72,29 @@ lazy val compat = new MultiScalaCrossProject( | |||
sharedSourceDir / "scala-2.11_2.12" | |||
} | |||
}, | |||
Test / unmanagedSourceDirectories += { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy paste from above, not sure how to factor things out in sbt
cc @martijnhoekstra, since you originally wrote |
this might interest @scala/collections |
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
compat/src/main/scala-2.11_2.12/scala/collection/compat/CompatImpl.scala
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Thank you @NthPortal! |
@lrytz can you fill in the PR description? |
to(Target)
conversions
👍 done |
oh, this is already released, awesome! |
In Scala 2.13,
collection.to(Target)
conversions return thecollection
object unchanged if it is immutable and is already a subtype of theTarget
type.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
to
is 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:
mapValues
returns a lazy map that's a subtype ofimmutable.Map
, so