Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged Anvil contributions always count as used #223

Open
RBusarow opened this issue Oct 17, 2021 · 0 comments
Open

Merged Anvil contributions always count as used #223

RBusarow opened this issue Oct 17, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@RBusarow
Copy link
Member

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?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant