bineanzhou / google-guice

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

untargeted bindings of parameterized types fail #247

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

This:

    new AbstractModule() {
        public void configure() {
            bind(new TypeLiteral<ArrayList<String>>() {}).in(Scopes.SINGLETON);
        }
    }

will fail with this message:

    1) No implementation for java.util.ArrayList<java.lang.String> was bound.

because BindingProcessor#visitUntargetted checks for this:

    type instanceof Class<?>

But if I modify visitUntargetted to do this:

if ( type instanceof ParameterizedType) {
    type = ((ParameterizedType)type).getRawType();
}

then everything is fine, and I get my ArrayList<String>.

Original issue reported on code.google.com by logan.jo...@gmail.com on 16 Sep 2008 at 3:59

GoogleCodeExporter commented 9 years ago
I should have mentioned this was found with 20080702 snapshot and the fix 
tested with
the current trunk.

Original comment by logan.jo...@gmail.com on 16 Sep 2008 at 4:02

GoogleCodeExporter commented 9 years ago
Will be addressed by issue 186.

Original comment by limpbizkit on 2 Nov 2008 at 9:20