Skip to content

scala.concurrent.Future.traverse( Range) does not compile #7390

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
scabug opened this issue Apr 18, 2013 · 2 comments
Closed

scala.concurrent.Future.traverse( Range) does not compile #7390

scabug opened this issue Apr 18, 2013 · 2 comments
Assignees

Comments

@scabug
Copy link

scabug commented Apr 18, 2013

import scala.concurrent._
import ExecutionContext.Implicits.global

Future.traverse(1 to    3)( Future.successful ) // compiles
Future.traverse(1 until 3)( Future.successful ) // compile error
error: Cannot construct a collection of type scala.collection.AbstractSeq[Int] 
with elements of type Int based on a collection of type scala.collection.AbstractSeq[Int].
   Future.traverse(1 until 3)( Future.successful )
                             ^

Is there a problem with generic.CanBuildFrom and Range ?

// example working with Range and Inclusive
def traverse[A,M[_]](list: M[A]) = 1

traverse(1 to    3)  // compiles
traverse(1 until 3)  // compiles!

Now the same example, but with generic.CanBuildFrom
(copied out off the source of scala.concurrent.Future.traverse)

// same example, CanBuildFrom added
import scala.collection.generic.CanBuildFrom

def traverse[A,M[_]](list: M[A])( implicit cbf: CanBuildFrom[M[A],A,M[A]] ) = 1

traverse(1 to    3)  // compiles
traverse(1 until 3)  // does not compile!

// needs a little help
traverse[Int,Seq](1 until 3) // does compile!

// the other way round
val incl: Range = 1 to 3
traverse( incl ) // does not compile!
@scabug
Copy link
Author

scabug commented Apr 18, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7390?orig=1
Reporter: Frank Teubler (dft)
Affected Versions: 2.10.1
Duplicates #6948

@scabug scabug closed this as completed Apr 19, 2013
@scabug
Copy link
Author

scabug commented Apr 19, 2013

@retronym said:
This is a variation of #6948, which stems from a weakness in type constructor inference and the addition of a new parant, AbstractSeq, in Scala 2.10.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants