scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

lower bounds make the wheels come off #6717

Open scabug opened 11 years ago

scabug commented 11 years ago

"inferred type arguments do not conform", you don't say. Hey scalac, that's what you get when you go around inferring polytypes!

scala> def f[T, CC[X] <: Traversable[X], DD[X] >: CC[X]](xs: CC[T])(implicit cbf: collection.generic.CanBuildFrom[Traversable[T], T, DD[T]]): DD[T] = xs.map(x => x)
warning: there were 2 feature warnings; re-run with -feature for details
f: [T, CC[X] <: Traversable[X], DD[X] >: CC[X]](xs: CC[T])(implicit cbf: scala.collection.generic.CanBuildFrom[Traversable[T],T,DD[T]])DD[T]

scala> f(1 to 10 toStream)
<console>:9: error: inferred type arguments [Int,scala.collection.immutable.Stream,[X]scala.collection.immutable.Stream] do not conform to method f's type parameter bounds [T,CC[X] <: Traversable[X],DD[X] >: CC[X]]
              f(1 to 10 toStream)
              ^
<console>:9: error: type mismatch;
 found   : scala.collection.immutable.Stream[Int]
 required: CC[T]
              f(1 to 10 toStream)
                        ^
<console>:9: error: Cannot construct a collection of type DD[T] with elements of type T based on a collection of type Traversable[T].
              f(1 to 10 toStream)
               ^
scabug commented 11 years ago

Imported From: https://issues.scala-lang.org/browse/SI-6717?orig=1 Reporter: @paulp