-
Notifications
You must be signed in to change notification settings - Fork 87
Make the breakOut rewrite rule cross compatible #80
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
Comments
Not as is. package fix
import scala.collection.compat._
object BreakoutSrc {
val xs = List(1, 2, 3)
xs.iterator.collect{ case x => x }.to(implicitly): Set[Int]
xs.iterator.flatMap(x => List(x)).to(implicitly): collection.SortedSet[Int]
xs.iterator.map(_ + 1).to(implicitly): Set[Int]
xs.reverseIterator.map(_ + 1).to(implicitly): Set[Int]
xs.iterator.scanLeft(0)((a, b) => a + b).to(implicitly): Set[Int]
xs.iterator.concat(xs).to(implicitly): Set[Int]
xs.view.updated(0, 1).to(implicitly): Set[Int]
xs.iterator.zip(xs).to(implicitly): Map[Int, Int]
xs.iterator.zipAll(xs, 0, 0).to(implicitly): Array[(Int, Int)]
(xs.iterator ++ xs).to(implicitly): Set[Int]
(1 +: xs.view).to(implicitly): Set[Int]
(xs.view :+ 1).to(implicitly): Set[Int]
(xs ++: xs.view).to(implicitly): Set[Int]
}
|
It looks like we should add |
|
It seems that it’s not possible with the current version of scalafix. |
@julienrf what if we do this: xs.iterator.zip(xs).to(Map[Int, Int]) Do we need to make sure the parameter of |
It would rather be: xs.iterator.zip(xs).to(Map) This means that we need to find a value that is (or can be converted to) a |
In most of the cases I guess people use But cases like the following won’t work: def foo[C](implicit cbf: CanBuildFrom[Nothing, Int, C]): C = {
val xs = List(1, 2, 3)
xs.map(_ + 1)(collection.breakOut) // the expected type is `C`
} |
Do you think it’s possible, @MasseGuillaume?
The text was updated successfully, but these errors were encountered: