Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No TypeLiteral for types taking a slick.dbio.DBIO as type parameter can be created #105

Open
carstenlenz opened this issue Jun 16, 2023 · 0 comments

Comments

@carstenlenz
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant