Open ALPSMAC opened 2 years ago
Interestingly https://github.com/yakivy/jam yields the same compiler error...
:facepalm: figured it out...
override lazy val observationTypesService: ObservationTypesService = wire[ObservationTypesService]
should have been:
override lazy val observationTypesService: ObservationTypesService = wire[ProductionObservationTypesService]
Still - error message isn't particularly helpful today... not sure if it's easy or possible to provide a more meaningful error message.
Let's keep this open, the compiler error should definitely be better
I appreicate that... I lost more time than I care to admit to my missing the recursive reference.
Also - macwire has been my go-to for Scala DI frameworks that are easy to teach to developers familiar with Java but new to Scala. It's great work and I hope that it will be as easy to use in Scala 3 as it has been for us in Scala 2! 😁
I've been working on a new project in Scala 3 and trying the Scala 3 support in Macwire and ran into a blocker.
I have the following:
Where the
ServicesModule
looks like:and the other modules that are in scope from the self-typing look very similar (i.e. ConfigModule, PoolsModule, DatabasesModule, etc.).
Note how I've declared the required dependencies into local scope since macwire in Scala 3 can't yet look up dependencies in parent scope. This seemed to work well for the other modules on which ServicesModule depends, but not in ServicesModule itself evidently.
In ServicesModule, the call to
wire
breaks with a cryptic compiler bug:Wasn't sure whether the best place to post this was here (since y'all are the experts on your macro generation) or the dotty github... but perhaps you can work with the dotty maintainers if you're able to reproduce - or perhaps you'll know what "-isms" to avoid to fix this error?
I tried making sure each class I was wiring had at least an empty constructor (i.e.
class ABC()
vsclass ABC
- although I'm not sure if at compile time the difference matters...) since'new' call to non-constructor: $init$
kind-of sounds like maybe macwire callednew
on a companion object or something? No luck though... and that's about where I ran out of ideas.Kind Regards, Andy