Well, I have something like this:
trait A
class Serving(a: => A)
object App extends Serving(App.Main) {
开发者_开发技巧 object Main extends A
}
And I get the error super constructor cannot be passed a self reference unless parameter is declared by-name
. I can work around by doing
object App extends Serving(Serv.Main)
object Serv {
object Main extends A
}
but I don't want to. It adds 2 extra .class
es and it strikes me as unelegant.
And using object App extends Serving(this.Main)
also creates an error. The structure of A
and Serving
cannot really be changed, but is there any way to work around this error?
Your code compiles just fine in Scala 2.8.1, even if the parameter is not declared by-name.
精彩评论