codingwell / scala-guice

Scala extensions for Google Guice
Apache License 2.0
341 stars 44 forks source link

Binding wildcard types doesn't use correct type literal #70

Closed Vrolijkx closed 6 years ago

Vrolijkx commented 6 years ago

I have problems with binding wildcard types in scala Guice. If you define a binding like bind[Container[_]].toInstance(someInstance) or bind[Containter[_ <: SomeImpl].toInstance(someInstance) then injections of these types into constructors/fields will fail. I have pinpointed the problem to the way scalaGuice generates a typeLiteral see spec below:

val typeLiteralScalaGuice = typeLiteral[Container[_ <: Impl1]]
val typeLiteralJavaWay = new TypeLiteral[Container[_ <: Impl1]] {}

typeLiteralJavaWay shouldEqual typeLiteralScalaGuice //this failes
tsuckow commented 6 years ago

Should be fixed in 4.2.1 Sorry about the delay