diff --git a/java/dagger/internal/codegen/binding/BindingGraph.java b/java/dagger/internal/codegen/binding/BindingGraph.java index 33a5c8f9a09..7659dc0b7e4 100644 --- a/java/dagger/internal/codegen/binding/BindingGraph.java +++ b/java/dagger/internal/codegen/binding/BindingGraph.java @@ -172,12 +172,17 @@ public ImmutableSet componentRequirements() { private ImmutableSet requiredModuleElements() { return stream(SUBGRAPH_TRAVERSER.depthFirstPostOrder(this)) - .flatMap(graph -> graph.contributionBindings().values().stream()) + .flatMap(graph -> graph.bindingModules().stream()) + .filter(ownedModuleTypes()::contains) + .collect(toImmutableSet()); + } + + @Memoized + protected ImmutableSet bindingModules() { + return contributionBindings().values().stream() .flatMap(bindings -> bindings.contributionBindings().stream()) .map(ContributionBinding::contributingModule) - .distinct() .flatMap(presentValues()) - .filter(ownedModuleTypes()::contains) .collect(toImmutableSet()); }