我有一些代码,比如说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
^