diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/checkreturnvalue/CanIgnoreReturnValueSuggesterTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/checkreturnvalue/CanIgnoreReturnValueSuggesterTest.java index 7aef62648193..905313686f24 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/checkreturnvalue/CanIgnoreReturnValueSuggesterTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/checkreturnvalue/CanIgnoreReturnValueSuggesterTest.java @@ -872,4 +872,58 @@ public void exemptedByCustomAnnotation() { .setArgs("-XepOpt:CanIgnoreReturnValue:ExemptingMethodAnnotations=example.Foo") .doTest(); } + + @Test + public void daggerComponentBuilder_b318407972() { + helper + .addInputLines( + "Builder.java", + "package com.google.frobber;", + "import dagger.Component;", + "@Component.Builder", + "interface Builder {", + " Builder setName(String name);", + " String build();", + "}") + .addOutputLines( + "Builder.java", + "package com.google.frobber;", + "import com.google.errorprone.annotations.CanIgnoreReturnValue;", + "import dagger.Component;", + "@Component.Builder", + "interface Builder {", + // TODO(b/318407972): we shouldn't suggest @CIRV on Dagger Component.Builder setters + " @CanIgnoreReturnValue", + " Builder setName(String name);", + " String build();", + "}") + .doTest(); + } + + @Test + public void daggerSubcomponentBuilder_b318407972() { + helper + .addInputLines( + "Builder.java", + "package com.google.frobber;", + "import dagger.Subcomponent;", + "@Subcomponent.Builder", + "interface Builder {", + " Builder setName(String name);", + " String build();", + "}") + .addOutputLines( + "Builder.java", + "package com.google.frobber;", + "import com.google.errorprone.annotations.CanIgnoreReturnValue;", + "import dagger.Subcomponent;", + "@Subcomponent.Builder", + "interface Builder {", + // TODO(b/318407972): we shouldn't suggest @CIRV on Dagger Subcomponent.Builder setters + " @CanIgnoreReturnValue", + " Builder setName(String name);", + " String build();", + "}") + .doTest(); + } }