michaelwiles / google-gin

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

Injecting wildcard results in compile-time error #121

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

@Inject
public FooTool(List<Bar<?>> bars) {

We set up  our binding like so:
@Provides
public List<Bar<?>> provideBarList(FooProvider2 f) {
 return f.get();
}

At compile time we get the following exception:
=========================================
java.lang.IllegalArgumentException: Not enough type arguments were
specified to parameterize
'com.google.ads.branding.adplanner.client.demographics.Feature<B>'
       at
com.google.gwt.core.ext.typeinfo.TypeOracle.getParameterizedType(TypeOracle.java
:
458)
       at
com.google.gwt.inject.rebind.util.KeyUtil.getClassType(KeyUtil.java:
131)
       at
com.google.gwt.inject.rebind.util.KeyUtil.getClassType(KeyUtil.java:
120)
       at
com.google.gwt.inject.rebind.util.KeyUtil.getClassType(KeyUtil.java:
108)
       at
com.google.gwt.inject.rebind.BindingsProcessor.createImplicitBinding(BindingsPro
cessor.java:
575)
       at
com.google.gwt.inject.rebind.BindingsProcessor.createImplicitBindingForUnresolve
d(BindingsProcessor.java:
286)
       at
com.google.gwt.inject.rebind.BindingsProcessor.createImplicitBindingsForUnresolv
ed(BindingsProcessor.java:
274)
       at
com.google.gwt.inject.rebind.BindingsProcessor.process(BindingsProcessor.java:
239)
       at
com.google.gwt.inject.rebind.GinjectorGeneratorImpl.generate(GinjectorGeneratorI
mpl.java:
76)
       at
com.google.gwt.inject.rebind.GinjectorGenerator.generate(GinjectorGenerator.java
:
47)
       at
com.google.gwt.dev.javac.StandardGeneratorContext.runGenerator(StandardGenerator
Context.java:
427)

What is the expected output? What do you see instead?
No exception, just injection of what we need

What version of the product are you using? On what operating system?
Default version (r146?)
Goobuntu

Original issue reported on code.google.com by s...@google.com on 25 Oct 2010 at 9:25

GoogleCodeExporter commented 9 years ago

Original comment by aragos on 25 Oct 2010 at 10:00

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

Original comment by aragos on 26 Oct 2010 at 9:47

GoogleCodeExporter commented 9 years ago
Fix submitted in r147.

Original comment by aragos on 27 Oct 2010 at 3:54

GoogleCodeExporter commented 9 years ago
This bug still happens in 1.0:

java.lang.IllegalArgumentException: Not enough type arguments were specified to 
parameterize 'java.util.Set<E>'
    at com.google.gwt.core.ext.typeinfo.TypeOracle.getParameterizedType(TypeOracle.java:458)
    at com.google.gwt.inject.rebind.util.KeyUtil.getClassType(KeyUtil.java:129)
    at com.google.gwt.inject.rebind.util.KeyUtil.getClassType(KeyUtil.java:106)
    at com.google.gwt.inject.rebind.BindingsProcessor.createImplicitBinding(BindingsProcessor.java:502)
    at com.google.gwt.inject.rebind.BindingsProcessor.createImplicitBindingForUnresolved(BindingsProcessor.java:237)
    at com.google.gwt.inject.rebind.BindingsProcessor.createImplicitBindingsForUnresolved(BindingsProcessor.java:225)
    at com.google.gwt.inject.rebind.BindingsProcessor.process(BindingsProcessor.java:217)
    at com.google.gwt.inject.rebind.GinjectorGeneratorImpl.generate(GinjectorGeneratorImpl.java:76)
    at com.google.gwt.inject.rebind.GinjectorGenerator.generate(GinjectorGenerator.java:47)
    at com.google.gwt.dev.javac.StandardGeneratorContext.runGenerator(StandardGeneratorContext.java:427)

Also when I try to bind with a @Named annotation it say's that there's no 
implementation bound.

No implementation bound for key Key[type=java.util.Set>, 
annotation=@com.google.inject.name.Named(value=name_value)]

When I bind this thing as an Object and cast it after it's injected it works 
fine.

Original comment by kuba.bochenski@gmail.com on 18 Jan 2011 at 9:14

GoogleCodeExporter commented 9 years ago
Yes, 1.0 was cut a long time ago now, before these fixes. A new release is 
coming up although it's currently blocked on Guice 3.0 being ready (Guice is 
going through RC right now).

Original comment by aragos on 18 Jan 2011 at 9:36