Modules.override() loses source information when the current source is skipped
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 1.7k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
_From [tavianator](https://code.google.com/u/tavianator@gmail.com/) on October 07, 2013 14:04:22_
This test case:
<code language="java">
Guice.createInjector(new AbstractModule() {
`@`Override
protected void configure() {
bind(String.class).toInstance("foo");
install(Modules.override(Modules.EMPTY_MODULE).with(new AbstractModule() {
`@`Override
protected void configure() {
binder().skipSources(getClass()).bind(String.class).toInstance("bar");
}
}));
}
});
</code>
Produces this error:
{{{
1) A binding to java.lang.String was already configured at Test$1.configure(Test.java:74).
at com.google.inject.util.Modules$RealOverriddenModuleBuilder$1.configure(Modules.java:172)
}}}
If the module is installed directly, without Modules.override(), it gives
{{{
1) A binding to java.lang.String was already configured at Test$1.configure(Test.java:74).
at Test$1.configure(Test.java:75)
}}}
instead, which is a lot more helpful.
This seems like a general issue with `Elements.getElements()`: there's no way to specify sources to skip, so the bindings it creates can't have sources from above the `Elements.getElements()` call.
_Original issue: http://code.google.com/p/google-guice/issues/detail?id=774_
Contributor guide
Assessment
This issue has not been assessed yet.