ModuleCheck
ModuleCheck copied to clipboard
Merged Anvil contributions always count as used
in :lib:
@MergeModule(AppScope::class)
object NetworkModule {
@Provides
fun provideService() : Service = ...
}
in :app:
@MergeComponent(AppScope::class)
interface AppComponent { ... }
... and that's it. No other code.
The NetworkModule contribution will make :lib count as "used". It should count as unused, because nothing is actually consuming that binding.
Inspecting the Anvil graph already requires a sort of reverse look-up. Dependency modules are parsed for contributions for a given scope, then the dependent module is parsed looking for (sub)components of that scope. If the dependent module has a matching component.
It should go a step further. The component module should only "use" the contributing dependency module if the component module has a dependency which consumes the binding.
This gets ugly fast.
- In Dagger modules, the module's return types need to be parsed in order to get the bound types.
- When binding an impl to an interface type, then dependencies will typically be for the interface type.
- Replaced bindings?