scala - scala 2.10.0 中高级类型的奇怪错误(适用于 scala 2.9.2)

标签 scala scala-2.10

此代码使用 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)
}

但是使用 Scala 2.10.0 它不会编译并出现以下错误(启用了更高级的语言功能):
[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)

这里会发生什么? Scala 2.10 中高级类型有哪些变化?

附言如果我显式传递类型参数,则此代码将编译:
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)
}

最佳答案

看起来像一个错误,很可能:
https://issues.scala-lang.org/browse/SI-5330

它应该在 Scala 2.10.1 中修复,如果您迫不及待,可以尝试发布候选版本:
http://www.scala-lang.org/2.10.1-RC3

关于scala - scala 2.10.0 中高级类型的奇怪错误(适用于 scala 2.9.2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15265741/

相关文章:

scala - 创建一个自定义 Scala 集合,其中 map 默认返回自定义集合?

Scala 2.10 反射 : Why do I get the same type "List()" for the list and list element?

java - 如何将不同的值传递给 scala 对象中的变量

arrays - Scala Array.apply 的魔力是什么

Scala Spark - 将元组的值映射到单个值

regex - Scala - 来自 URL 的 Youtube 视频 ID

scala:将 null 分配给原语

scala - 如何删除具有过多 NULL 值的行?

scala - 将自定义谓词传递给 TableQuery 的过滤方法

validation - 通过 for-comprehension 线程 `Try` s