-
Notifications
You must be signed in to change notification settings - Fork 44
Binding of generic types #65
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
Comments
I can't think of a good reason. Every so often I try to fix some of these more nuanced issues but it inevitably triumphs over me. PR's welcome. |
OK, I'll do my best. |
I don't know that I ever claimed to be semver. There is also the argument about whether fixing an unexpected behaviour is "breaking". |
I think with changes in 4.2.1 this is now "fixable." But I am having a hell of a time making a test case. I tried "allow binding by name to Unit" in {
val foo:(=> Unit) => String = (a) => "dog"
val module = new AbstractModule with ScalaModule {
override def configure() = {
bind[(=> Unit) => String].toInstance(foo)
bindInterceptor[AOPI](methodMatcher = annotatedWith[AOP])
}
}
import net.codingwell.scalaguice.InjectorExtensions._
val injector = Guice.createInjector(module)
val func = injector.instance[(=> Unit) => String]
func shouldEqual foo
} But this results in [info] - should allow binding by name to Unit *** FAILED *** Which I assume is meaning |
I fiddled with this again and made 1 tweak in 4.2.8 that However it seems the the reflection to find a Java type for |
I have issue with binding some generic types, namely
bind[Unit => String]
andbind[(=> Unit) => String]
. Guice itself is able to both bind and inject types like this, but current implementation of this library stops me from doing that, because:bind[Unit => String]
Unit
is converted toVoid
, but only for binding thus the binding is not found when injectingbind[(=> Unit) => String]
(=> Unit) => String
is in factFunction1[Function0[Unit], String]
but compiler is unable to generateManifest
for thatI would like to ask if there is some reason why the
Unit
is converted toVoid
.I would be very happy to fix it (it's easily solvable by a short macro which I already wrote for myself as a workaround), I just want to be sure there's not some good reason for having it like these.
Thx.
The text was updated successfully, but these errors were encountered: