In conjunction with experimenting with Cats, I’ve been testing out the -Ypartial-unification
flag. It seems to break what seems like a simple use case when I try to traverse over a Map
.
Does anybody know whether this an expected issue, or is it a bug in the unification code? If the latter, I’ll happily file an issue.
Here’s my test code:
import scala.concurrent._
import ExecutionContext.Implicits.global
object test {
val m = Map("a" -> 2)
Future.traverse(m) { a => Future(()) }
}
When I do scalac test.scala
it succeeds, but I get the following failure with partial unification.
> scalac -Ypartial-unification test.scala
test.scala:5: error: inferred type arguments [Int,Nothing,[+B]Map[String,B]] do not conform to method traverse's type parameter bounds [A,B,M[X] <: TraversableOnce[X]]
Future.traverse(m) { a => Future(()) }
^
test.scala:5: error: type mismatch;
found : Map[String,Int]
required: M[A]
Future.traverse(m) { a => Future(()) }
I can work around this by doing Future.traverse(m: Iterable[(String, Int)]) { … }
, but this seems like either a bug or an unfortunate problem that will exist in the standard library if partial unification becomes standard.