Allow using ContributesTo to contribute provisions #728
Description
The goal would be to allow writing this
@ContributesTo(AppScope::class)
fun provideOkHttpClient(): OkHttpClient = ...
which generates something equivalent to
@Module
@ContributesTo(AppScope::class)
object OkHttpClientModule {
fun provideOkHttpClient(): OkHttpClient = ...
}
This would almost completely avoid the need to create module classes. Other than plain injected classes any contribution to a component would then use a @Contributes...
annotation and we wouldn't need another concept like modules. The only scenario that I can think of where you'd still need a module is generic bindings but the most common case for them would be addressed by #726). The original motivation comes from this thread https://androiddev.social/@[email protected]/110722092128294953
An implementation would need to handle scope and qualifier annotations (edit: also multibinding annotations) on the function as well as parameters to the function and their annotations.
It would also be possible to create a @ContributesProvides
annotation for this but it would have the same parameters.
If this is something you'd want to support I can take a stab at implementing it.
Activity