Skip to content

Commit 058b079

Browse files
garabaisDagger Team
authored andcommitted
Fix Dagger multibinding duplicate tracking for Maps
Currently, Dagger only verifies duplicate map key contributions within the same component. Contributions with duplicate keys across the component hierarchy are ignored, resulting in masked values or runtime crashes when backed by Guava. This change introduces strict duplicate detection across the full map binding graph. Dagger now performs compile-time verification to reject duplicate map keys across the entire component hierarchy. This behavior is controlled by the new compiler option -Adagger.mapMultibindingDuplicateDetectionFix. When enabled, strict duplicate tracking is enforced across the component hierarchy. RELNOTES=Fixed Dagger multibinding duplicate masking across Map components (compile-time validation). PiperOrigin-RevId: 915631609
1 parent e5a0a12 commit 058b079

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

dev-guide/compiler-options.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,23 @@ especially true when dealing with Kotlin sources, where wildcards must be
170170
interpreted indirectly from a number of factors other than the explicit variance
171171
at the use site.
172172

173+
## Detect duplicate map multibinding contributions across component boundaries {#map-multibinding-duplicate-detection-fix}
174+
175+
The `dagger.mapMultibindingDuplicateDetectionFix` flag fixes a bug in Dagger
176+
where duplicate multibinding map keys were allowed in certain situations.
177+
When the flag is enabled Dagger should enforce strict duplicate checking of map
178+
multibinding contributions (e.g., identical `@IntoMap` bindings) across
179+
component boundaries.
180+
181+
By default, this flag is disabled, meaning Dagger preserves the legacy lenient
182+
behavior and ignores duplicate map key contributions across component
183+
boundaries.
184+
185+
To opt-in to strict duplicate detection at compile time (for Maps), enable the
186+
flag by passing the following compiler option:
187+
188+
`-Adagger.mapMultibindingDuplicateDetectionFix=ENABLED`
189+
173190
<!-- References -->
174191

175192
[`@Component`]: https://dagger.dev/api/latest/dagger/Component.html

0 commit comments

Comments
 (0)