Skip to content

Commit 2c6417d

Browse files
java-team-github-botError Prone Team
authored andcommitted
Add dagger.Subcomponent.Factory to the list of classes where qualifier may be allowed.
This replaces `dagger.Subcomponent.Builder.Factory` which does not exist, and which may have been a typo? Subcomponent Factory methods typically have parameters annotated with `@BindsInstance` to bind parameters, and as such, primitives like booleans often need additional qualifier annotations. PiperOrigin-RevId: 789429021
1 parent 3cd9429 commit 2c6417d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

core/src/main/java/com/google/errorprone/bugpatterns/UnnecessaryQualifier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ private static ImmutableList<AnnotationTree> getQualifiers(
213213
"dagger.Component.Factory",
214214
"dagger.Subcomponent",
215215
"dagger.Subcomponent.Builder",
216-
"dagger.Subcomponent.Builder.Factory",
216+
"dagger.Subcomponent.Factory",
217217
"dagger.hilt.EntryPoint",
218218
"dagger.producers.ProductionComponent",
219219
"dagger.producers.ProductionComponent.Builder",

core/src/test/java/com/google/errorprone/bugpatterns/UnnecessaryQualifierTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,23 @@ interface Builder {
195195
.doTest();
196196
}
197197

198+
@Test
199+
public void exemptedClassAnnotation_subcomponentFactory_noFinding() {
200+
helper
201+
.addSourceLines(
202+
"Test.java",
203+
"""
204+
import dagger.BindsInstance;
205+
import dagger.Subcomponent;
206+
207+
@Subcomponent.Factory
208+
interface Factory {
209+
Object create(@BindsInstance @Qual boolean isEnabled);
210+
}
211+
""")
212+
.doTest();
213+
}
214+
198215
@Test
199216
public void lambdas_neverMeaningful() {
200217
helper

0 commit comments

Comments
 (0)