forked from benlings/scala-guice
-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Description
Hi,
doing something like in this example:
import com.google.inject.Guice
import net.codingwell.scalaguice.InjectorExtensions.ScalaInjector
import net.codingwell.scalaguice.ScalaModule
import slick.dbio.DBIO
import scala.util.Try
object ModuleTesting {
def main(args: Array[String]): Unit = {
val injector = Guice.createInjector(new TestModule)
val inst = injector.instance[MyTF[Try]]
val inst2 = injector.instance[MyTF[DBIO]]
}
}
class TestModule extends ScalaModule {
override def configure(): Unit = {
bind[MyTF[Try]]
bind[MyTF[DBIO]]
}
}
class MyTF[F[_]] {}gives the following error:
java.lang.UnsupportedOperationException: Could not convert scalaType slick.dbio.DBIO to a javaType: scala.reflect.internal.Types$AliasNoArgsTypeRef
at net.codingwell.scalaguice.TypeConversions$.scalaTypeToJavaType(TypeConversions.scala:99)
at net.codingwell.scalaguice.TypeConversions$.$anonfun$scalaTypeToJavaType$1(TypeConversions.scala:82)
at scala.collection.immutable.List.map(List.scala:246)
at scala.collection.immutable.List.map(List.scala:79)
at net.codingwell.scalaguice.TypeConversions$.scalaTypeToJavaType(TypeConversions.scala:82)
at net.codingwell.scalaguice.package$.typeLiteral(package.scala:35)
at net.codingwell.scalaguice.InternalModule$BindingBuilder.<init>(ScalaModule.scala:77)
at net.codingwell.scalaguice.InternalModule.bind(ScalaModule.scala:82)
at net.codingwell.scalaguice.InternalModule.bind$(ScalaModule.scala:82)
...
As a workaround either constructing TypeLiterals manually (new TypeLiteral[MyTF[DBIO]] {}) or using @Provide methods works.
Metadata
Metadata
Assignees
Labels
No labels