Closed henieek closed 8 years ago
Looks like this is a partial duplicate of #236, with the addition that same Subcomponents in different packages with the same name must be deduped as well.
@ronshapiro I prepared a fix for this, seems like it works well for my app. Tests are passing, not sure if it doesn't break anything though. Check it out: https://github.com/partition/dagger/commit/66f5bcf38223257db03a8aa53a4ad7f75618eade
A fix for this was submitted internally (and will be linked to this issue when synced with Github). When conflicting simple names are encountered, we're going to continue prepending parts of the FQCN to the Subcomponent impl name until we get unique names. So in the case of com.example.Bar.Foo
and com.example.baz.Foo
you'd get Bar_FooImpl
and baz_FooImpl
.
Hey there,
I tried to find some existing reports regarding this issue but I couldn't find anything related.
My usecase: I use Dagger2 in my Android app and I have one, big ApplicationComponent that keeps all the application-wide dependencies. Then I have bunch of subcomponents, that are connecting to the ApplicationComponent extending it by some additional dependencies. These subcomponents (and their modules) are inner interfaces and inner classes residing within injectee-classes scopes. E.g.:
And then within the ApplicationComponent:
I wanted to avoid creating monster-looking names like MyCoolAndroidServiceComponent and MyCoolAndroidServiceModule thus I planned to keep all these names as above. Unfortunately - it seems to be impossible task with Dagger2 due to its way of generating code. The outcome for me is:
(Note: the same thing happens if your same-named subcomponents are top-level classes, but reside in two different packages).
Is it something you know about already? I may come up with some pull-request fixing that issue if you think it would be helpful.