I have a class AppComponents
in AppLoader.scala
in projectDir/app
My tests are in projectDir/test/ControllerSpec/UserControllerSpec.scala
In UserControllerSpec.scala
, I tried to create an instance of AppComponents
but the compiler couldn't find the AppComponents
class
override def components: BuiltInComponents = new AppComponents(context) //doesn't compile
But if I include statement package app
in Apploader.scala
then the compiler is able to find AppComponents
and the above code compiles.
I don't understand this behavior.
So
AppComponents
should only be visible to other classes/traits/etc. outside a package. Becauseit looks like
UserControllerSpec
does declare a package and can't see the empty package's members.This behavior is probably for consistency with Java, see answers to Import package with no name Java.