0

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 .classes 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?

Andrii Abramov
  • 10,019
  • 9
  • 74
  • 96
Lanbo
  • 15,118
  • 16
  • 70
  • 147

1 Answers1

1

Your code compiles just fine in Scala 2.8.1, even if the parameter is not declared by-name.

Aaron Novstrup
  • 20,967
  • 7
  • 70
  • 108
  • And this example compiles with 2.9.0, too... Okay, 8 hours of coding are too much. Sorry to have bothered you people! – Lanbo May 13 '11 at 19:32