I did a tiny code test, and it seems like this is already going to fail at initial start time (note: not compilation time).
object Test {
import net.codingwell.scalaguice.InjectorExtensions._
class FooService
class MyObject @Inject() (foo: FooService)
class InjectionTest @Inject() (inj: Injector) {
def doTest() = inj.instance[MyObject]
}
def main(args: Array[String]): Unit = {
val injector = Guice.createInjector(new ScalaModule() {
override def configure(): Unit = {
binder().requireExplicitBindings()
bind[MyObject]
bind[InjectionTest].asEagerSingleton()
}
})
injector.instance[InjectionTest].doTest()
}
}
The error is this (rightly so):
Exception in thread "main" com.google.inject.CreationException: Guice creation errors:
1) Explicit bindings are required and Test$FooService is not explicitly bound.
while locating Test$FooService
for parameter 0 at Test$MyObject.<init>(Test.scala:22)
at Test$$anon$1.bind(Test.scala:27)
Did you test the behavior already, or were you just curious of the behavior? It seems to work the way you want it to.