Add dagger.strictAssistedInjectValidation option to validate @AssistedInject and @AssistedFactory in dependencies. - #5283
Merged
Conversation
…tedInject and @AssistedFactory in dependencies. In `fastInit` mode, consuming `@AssistedInject` classes and `@AssistedFactory` interfaces from libraries that did not run Dagger's annotation processor previously compiled by chance. This occurred because `fastInit` generates assisted factory implementations inline, and Dagger's component processing accidentally generated missing `_Factory` classes for `@AssistedInject` (a behavior only intended for standard `@Inject` constructors). However, in standard compilation mode, this same library configuration fails to compile because Dagger requires the pre-generated classes to exist on the classpath. This creates an undesirable disparity where code compiles in `fastInit` mode but fails in standard mode. This change adds a new compiler option, `dagger.strictAssistedInjectValidation`. When enabled (`-Adagger.strictAssistedInjectValidation=ENABLED`), Dagger ensures parity across all compilation modes by preventing accidental on-the-fly generation in `fastInit` and validating that pre-generated `_Factory` and `_Impl` classes exist on the classpath. If they are missing, Dagger reports a clear compilation error advising the user to apply the Dagger annotation processor to the library dependency. RELNOTES=Added the option `-Adagger.strictAssistedInjectValidation=ENABLED` to validate that libraries defining `@AssistedInject` or `@AssistedFactory` ran the Dagger annotation processor. PiperOrigin-RevId: 988595397
copybara-service
Bot
force-pushed
the
test_943392337
branch
from
September 26, 2026 00:55
52f81d2 to
cf791f3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
dagger.strictAssistedInjectValidationoption to validate @AssistedInject and @AssistedFactory in dependencies.In
fastInitmode, consuming@AssistedInjectclasses and@AssistedFactoryinterfaces from libraries that did not run Dagger's annotation processor previouslycompiled by chance. This occurred because
fastInitgenerates assisted factory implementations inline, and Dagger's component processing accidentally generatedmissing
_Factoryclasses for@AssistedInject(a behavior only intended for standard@Injectconstructors).However, in standard compilation mode, this same library configuration fails to compile because Dagger requires the pre-generated classes to exist on the
classpath. This creates an undesirable disparity where code compiles in
fastInitmode but fails in standard mode.This change adds a new compiler option,
dagger.strictAssistedInjectValidation. When enabled (-Adagger.strictAssistedInjectValidation=ENABLED), Dagger ensuresparity across all compilation modes by preventing accidental on-the-fly generation in
fastInitand validating that pre-generated_Factoryand_Implclassesexist on the classpath. If they are missing, Dagger reports a clear compilation error advising the user to apply the Dagger annotation processor to the library
dependency.
RELNOTES=Added the option
-Adagger.strictAssistedInjectValidation=ENABLEDto validate that libraries defining@AssistedInjector@AssistedFactoryran the Dagger annotation processor.