Closed ahrussell closed 2 years ago
After debugging we found out it's related to this: https://users.scala-lang.org/t/fields-in-object-is-now-static-in-2-13/5873 and a change in Scala 2.13 that makes objects have static fields
I have found this would help: snippet
I'm glad you seem to have found workarounds. It seems it was amazing this worked at all since object
implies a static object though for implementation reasons in scala wasn't apparently actually static. Google-Guice also seems to explicitly not endorse injecting into static fields.
With that in mind since this seems to be a Scala language vs Google-Guice issue and not directly related to Scala-Guice I'm going to close this ticket. If anyone has more tips or tricks they want to share feel free to continue the conversation.
On versions 4.2.5, 4.2.9, and 5.0.1 (the ones I tested),
Injector.injectMembers
fails on Scala 2.13.6. Minimal repro:You can play around with this example (changing the Scala version from 2.12.13 to 2.13.6) here.