I recently migrated my app to Scala 3 and started seeing the following error with Macwire.
class SlickProductRepository extends ProductRepository[DBIO] { }
class ProductService[F[_], DB[_]: Monad](
repository: ProductRepository[DB],
dbManager: DatabaseManager[F, DB]
)
import slick.dbio.*
import foo.bar.DBIOInstances.*
trait MainModule {
lazy val dbManager: SlickDatabaseManager = wire[SlickDatabaseManager]
lazy val productRepository = wire[SlickProductRepository]
lazy val productService = wire[ProductService[Future, DBIO]] // fails
}
I am using slick-cats to get a Monad[DBIO]
. Since the lib doesn’t have a Scala 3 version yet, I copied the source to my project and imported the relevant implicits to MainModule
Error log
[error] -- Error: /project-name/src/main/scala/foo/bar/MainModule.scala:45:36
[error] 45 | lazy val productService = wire[ProductService[Future, DBIO]]
[error] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error] |Exception occurred while executing macro expansion.
[error] |java.lang.AssertionError: assertion failed
[error] | at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
[error] | at scala.quoted.runtime.impl.QuotesImpl$reflect$Ref$.apply(QuotesImpl.scala:444)
[error] | at scala.quoted.runtime.impl.QuotesImpl$reflect$Ref$.apply(QuotesImpl.scala:443)
[error] | at com.softwaremill.macwire.internals.ConstructorCrimper.paramType(ConstructorCrimper.scala:92)
[error] | at com.softwaremill.macwire.internals.ConstructorCrimper.wireConstructorParamsWithImplicitLookups$$anonfun$4$$anonfun$3(ConstructorCrimper.scala:75)
[error] | at scala.collection.immutable.List.map(List.scala:246)
[error] | at com.softwaremill.macwire.internals.ConstructorCrimper.wireConstructorParamsWithImplicitLookups$$anonfun$1(ConstructorCrimper.scala:75)
[error] | at scala.collection.immutable.List.map(List.scala:246)
[error] | at com.softwaremill.macwire.internals.ConstructorCrimper.wireConstructorParamsWithImplicitLookups(ConstructorCrimper.scala:76)
[error] | at com.softwaremill.macwire.internals.ConstructorCrimper.constructorArgs$$anonfun$3$$anonfun$1(ConstructorCrimper.scala:57)
[error] | at scala.Option.map(Option.scala:242)
[error] | at com.softwaremill.macwire.internals.ConstructorCrimper.constructorArgs$$anonfun$2(ConstructorCrimper.scala:57)
[error] | at com.softwaremill.macwire.internals.Logger.withBlock(Logger.scala:15)
[error] | at com.softwaremill.macwire.internals.ConstructorCrimper.constructorArgs(ConstructorCrimper.scala:58)
[error] | at com.softwaremill.macwire.internals.ConstructorCrimper.constructorTree$$anonfun$5$$anonfun$3(ConstructorCrimper.scala:63)
[error] | at scala.Option.flatMap(Option.scala:283)
[error] | at com.softwaremill.macwire.internals.ConstructorCrimper.constructorTree$$anonfun$2(ConstructorCrimper.scala:67)
[error] | at com.softwaremill.macwire.internals.Logger.withBlock(Logger.scala:15)
[error] | at com.softwaremill.macwire.internals.ConstructorCrimper.constructorTree(ConstructorCrimper.scala:68)
[error] | at com.softwaremill.macwire.MacwireMacros$.wire(MacwireMacros.scala:54)
[error] | at com.softwaremill.macwire.MacwireMacros$.wireImpl(MacwireMacros.scala:14)
[error] |
[error] |----------------------------------------------------------------------------
[error] |Inline stack trace
[error] |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error] |This location contains code that was inlined from package.scala:4
[error] ----------------------------------------------------------------------------
[error] one error found
Is this a known issue, or am I missing something? Can someone help me with this?