1
假設我有一個代碼:如何在Scala中重寫類型成員函數?
class C extends A#B {
override def fun(): Int = 100
}
trait A {
type B = {
def fun(): Int
}
}
編譯器說:
class type required but Object{def fun(): Int} found
class C extends A#B {
^
我怎麼能理解錯誤?