Skip to content

Not Supported breakOut rewrite #93

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

Closed
MasseGuillaume opened this issue Jul 11, 2018 · 1 comment
Closed

Not Supported breakOut rewrite #93

MasseGuillaume opened this issue Jul 11, 2018 · 1 comment

Comments

@MasseGuillaume
Copy link
Contributor

https://github.com/akka/akka/blob/d76b27ba3ecf747743d1fc6abd3163f78c9c60d8/akka-persistence/src/main/scala/akka/persistence/snapshot/local/LocalSnapshotStore.scala#L76-L81

  override def deleteAsync(persistenceId: String, criteria: SnapshotSelectionCriteria): Future[Unit] = {
    val metadatas = snapshotMetadatas(persistenceId, criteria)
    Future.sequence {
      metadatas.map(deleteAsync)
    }(collection.breakOut, streamDispatcher).map(_  ())(streamDispatcher)
  }
@MasseGuillaume
Copy link
Contributor Author

MasseGuillaume commented Jul 18, 2018

This breakOut is a no-op:

def sequence[A, M[X] <: TraversableOnce[X]](in: M[Future[A]])(implicit cbf: CanBuildFrom[M[Future[A]], A, M[A]], executor: ExecutionContext): Future[M[A]]
def traverse[A, B, M[X] <: TraversableOnce[X]](in: M[A])(fn: (A)  Future[B])(implicit cbf: CanBuildFrom[M[A], B, M[B]], executor: ExecutionContext): Future[M[B]]

The M does not change. It's only a default parameter to set an ExecutionContext

For example, this does not compile:

import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
Future.sequence(List(Future(1)))(breakOut, global): Future[Vector[Int]]
Future.traverse(List(1))(x => Future(x))(breakOut, global): Future[Vector[Int]]
// type mismatch;
// found   : scala.concurrent.Future[List[Int]]
// required: scala.concurrent.Future[Vector[Int]]
//  Future.sequence(List(Future(1)))(breakOut, global): Future[Vector[Int]]
//                 ^
// type mismatch;
// found   : scala.concurrent.Future[List[Int]]
// required: scala.concurrent.Future[Vector[Int]]
//  Future.traverse(List(1))(x => Future(x))(breakOut, global): Future[Vector[Int]]
//                 ^

It's possible to change the collection type:

import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
Future.sequence(List(Future(1)))(breakOut, global): Future[Seq[Int]]
Future.traverse(List(1))(x => Future(x))(breakOut, global): Future[Seq[Int]]

MasseGuillaume added a commit to MasseGuillaume/scala-collection-compat that referenced this issue Jul 19, 2018
MasseGuillaume added a commit to MasseGuillaume/scala-collection-compat that referenced this issue Jul 19, 2018
MasseGuillaume added a commit to MasseGuillaume/scala-collection-compat that referenced this issue Jul 19, 2018
MasseGuillaume added a commit to MasseGuillaume/scala-collection-compat that referenced this issue Jul 20, 2018
MasseGuillaume added a commit to MasseGuillaume/scala-collection-compat that referenced this issue Jul 20, 2018
MasseGuillaume added a commit to MasseGuillaume/scala-collection-compat that referenced this issue Jul 23, 2018
MasseGuillaume added a commit to MasseGuillaume/scala-collection-compat that referenced this issue Jul 23, 2018
julienrf added a commit that referenced this issue Jul 23, 2018
Make the breakOut rewrite rule cross compatible (fix #80) (fix #93)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant