First of all you probably know that access to inner classes is via the dot (.) operator. So accessing the Handler
class should be Outer.Handler
. When you're in scope this
the compiler cannot locate the Handler
class, because the inner class is tied to the outer object. Everything is explained much better here: http://www.scala-lang.org/node/115. In short you get a quite impossible situation, because the inner class is hidden inside the outer class, but an actual instantiation of the outer class requires the inner class...
There are many ways to solve it I guess, I'll just quickly sketch one here. Since you probably want the Handler
class to be tied to Outer
in some way, I'd recommend creating and object and then calling the Outer class from here. Thus you'd get roughly the same syntax and everything is stored in one place. It could look something like this:
class Outer(private val handler : Actor)
object Outer {
class Handler extends Actor { override def act { } } // The "inner" class
def apply() = new Outer(new Handler)
def apply(handler : Actor) = new Outer(handler)
}
Hope that helps :)