fmgasparino / google-gin

Automatically exported from code.google.com/p/google-gin
Apache License 2.0
0 stars 0 forks source link

A<? super B> is needed, but GIN looks for A<? extends B> #69

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create class
class C {
 @Inject C(A<? super B>) {}
}

2. bind implementation of A<? super B> in GIN, e.g.:

 bind(new TypeLiteral<A<? super B>>(){ }).to(D.class)

3. Request C from Ginjector

What is the expected output? What do you see instead?
Instance of class D should be injected into C.
Instead an exception is thrown: com.google.inject.ProvisionException: Guice
provision errors:

 1) Can't get class type for ? extends B

 1 error

-----
If the requested/provided classes are annotated with @Named the result is:
No implementation bound for key Key[type=A<? extends B>,
annotation=@com.google.inject.name.Named(value=TheNameEntered)]

4. Workaround
Bind to A<? extends B>, e.g.:

bind(new TypeLiteral<A<? extends B>>(){ }).to(D.class)

Original issue reported on code.google.com by bochensk...@gmail.com on 7 Dec 2009 at 1:30

GoogleCodeExporter commented 9 years ago
Yes, I think I recently saw this bug in the code, will try to fix it quickly.

Original comment by aragos on 8 Dec 2009 at 2:21

GoogleCodeExporter commented 9 years ago
Fix submitted for review: http://codereview.appspot.com/165095

Please review this (simple) change so it can go in quickly!

Original comment by aragos on 8 Dec 2009 at 9:44

GoogleCodeExporter commented 9 years ago
Fixed in r125.

Original comment by aragos on 21 Dec 2009 at 11:01