sgkhode / google-gin

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

No message appears in ambiguous cases #37

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
My Module provides values of same type:

public class MyModule extends AbstractGinModule {

    @Provides @Apple
    public Label getApple() {
        return new Label("apple");
    }

    @Provides @Lemon
    public Label getLemon() {
        return new Label("lemon");
    }
}

If I use injector with no annotation, GIN not say me about any warning signs:

@GinModules(MyModule.class)
public interface MyGinjector extends Ginjector {
    Label getLabel();
}

Is it wishful behaviour ?

Original issue reported on code.google.com by blacklit...@gmail.com on 14 May 2009 at 1:36

GoogleCodeExporter commented 8 years ago
Here's the problem. For any binding not explicitly provided, Gin falls back to
calling GWT.create() (GWT.create(Label.class) in your case). This is super 
convenient
because it lets you magically inject things created via deferred binding like
Messages. This is not that different than Guice trying to fall back to calling a
public no-arg constructor.

Agree this can make error detection a bit more difficult, but not sure how we 
could
improve that without removing the automatic GWT.create thing.

Original comment by bstoler+code@google.com on 14 May 2009 at 5:11