我有一些代码,说在Foo.scala
与容易编译scalac
,但我得到错误的暴风雪,当我启动了REPL说:load Foo.scala
。 我想这是标准和记载,但似乎无法找到关于它的任何相关信息。
该文件是这样的:
abstract class BST[A](implicit cmp: A => Ordered[A]) {
def fold[B](f: (B, A) => B, acc: B): B = {
this match {
case Leaf() => acc
}
}
}
case class Leaf[A]()(implicit cmp: A => Ordered[A]) extends BST[A]
而我得到像这样的错误:
scala> :load BST3.scala
Loading BST3.scala...
<console>:10: error: constructor cannot be instantiated to expected type;
found : Leaf[A(in class Leaf)]
required: BST[A(in class BST)]
case Leaf() => acc
^