This code compiles with Scala 2.9.2:
trait HK {
type Rep[A]
def unzip1[A, B, C[_]](ps: Rep[C[(A, B)]]): (Rep[C[A]], Rep[C[B]])
def doUnzip1[A, B](ps: Rep[List[(A, B)]]) = unzip1(ps)
}
But with Scala 2.10.0 it doesn't compile with the following error (higherKinded language feature is enabled):
[info] Compiling 1 Scala source to /home/klyuchnikov/code/hk/target/scala-2.10/classes...
[error] /home/klyuchnikov/code/hk/src/main/scala/HK.scala:6: type mismatch;
[error] found : HK.this.Rep[List[(A, B(in method doUnzip1))]]
[error] required: HK.this.Rep[List[((A, B(in method doUnzip1)), B(in method unzip1))]]
[error] def doUnzip1[A, B](ps: Rep[List[(A, B)]]) = unzip1(ps)
What happens here? What was changes in higher-kinded types in Scala 2.10?
P.S. If I pass type parameters explicitly, then this code compiles:
trait HK {
type Rep[A]
def unzip1[A, B, C[_]](ps: Rep[C[(A, B)]]): (Rep[C[A]], Rep[C[B]])
def doUnzip1[A, B](ps: Rep[List[(A, B)]]) = unzip1[A, B, List](ps)
}
Looks like a bug, most likely: https://issues.scala-lang.org/browse/SI-5330
It should be fixed in Scala 2.10.1, if you can't wait you may try release candidate: http://www.scala-lang.org/2.10.1-RC3
来源:https://stackoverflow.com/questions/15265741/strange-error-with-higher-kinded-types-in-scala-2-10-0-works-with-scala-2-9-2