我有一个主基类,我想扩展它,以便主类为扩展类提供基本功能:
class Foo extends App {
println("Foo")
def bar = {}
}
class Foo2 extends Foo {
println("Foo2")
}
object Foo2 extends Foo2 {
}
但这行不通。汇编抱怨
warning: Foo2 has a main method with parameter type Array[String], but Foo2 will not be a runnable program.
Reason: companion contains its own main method, which means no static forwarder can be generated.
如何实现这一目标?