Skip to content

Improve error message when Dagger compiler not run over module - #5245

Open
arimu1 wants to merge 1 commit into
google:masterfrom
arimu1:fix/5146-module-missing-factory-error
Open

Improve error message when Dagger compiler not run over module#5245
arimu1 wants to merge 1 commit into
google:masterfrom
arimu1:fix/5146-module-missing-factory-error

Conversation

@arimu1

@arimu1 arimu1 commented Aug 7, 2026

Copy link
Copy Markdown

Summary

When a @Module lives in a dependency that was compiled without the Dagger annotation processor / KSP plugin, generated component code references missing *Factory types and the user only sees a vague javac "does not exist" error.

This PR detects that situation during component validation and reports a clear diagnostic:

The Dagger factory type lib.LibraryModule_ProvideStringFactory is missing. This usually means the Dagger compiler was not applied to the module lib.LibraryModule where the binding is defined. Ensure that the dependency that contains that module runs the Dagger annotation processor (or KSP plugin).

Approach (aligned with option 1 from #5146, using the existing knownModules set so it works for both Javac and KSP):

  • Modules processed in the current compilation are recorded via ModuleValidator.addKnownModules (as before).
  • For transitive modules on a component that are not from the current compilation, require that each @Provides / @Produces factory exists on the classpath.
  • Skip modules from the current compilation: their factories are generated in-round by ModuleProcessingStep and may not yet be visible via findTypeElement.
  • @Binds-only modules do not require factories and are unaffected.

Fixes #5146

Test plan

When a @module from a dependency is missing its generated *Factory
types (because dagger-compiler/KSP was not applied to that library),
report a clear error instead of letting javac fail with a vague
"does not exist" message on the generated component.

Modules being compiled in the current compilation are skipped, since
their factories are generated in-round by ModuleProcessingStep and may
not yet be visible via findTypeElement.

Fixes google#5146
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better error message when Dagger compiler not run over module.

1 participant