forked from benlings/scala-guice
-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
This throws java.lang.reflect.MalformedParameterizedTypeException. I think the problem is Guice depends on Java reflection which cannot properly interpret AnyVal, as I cannot assign null to the initial value of Foo in BarProvider, since Foo is not bounded by Null
class Foo(val foo: String) extends AnyVal {}
object Foo {
def apply(foo: String): Foo = new Foo(foo)
def empty: Foo = new Foo("")
}
import com.google.inject._
import net.codingwell.scalaguice._
class BarProvider extends Provider[String] {
@Inject val foo: Foo = Foo.empty
def get() = foo.toString()
}
class Module extends AbstractModule with ScalaModule {
def configure() {
bind[Foo].toInstance(Foo("abc"))
bind[String].toProvider[BarProvider]
}
}
import net.codingwell.scalaguice.InjectorExtensions._
val injector = Guice.createInjector(new Module)
Console.println(injector.instance[String])
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels