From 195b3d6d8deb2b0dcc2afd1cec6209d0aa0b758f Mon Sep 17 00:00:00 2001 From: Kurt Alfred Kluever Date: Wed, 3 Jan 2024 09:03:03 -0800 Subject: [PATCH] Add a tests for Dagger `Component.Builder`s and `Subcomponent.Builder`s to `CanIgnoreReturnValueSuggesterTest`. #checkreturnvalue PiperOrigin-RevId: 595416843 --- .../CanIgnoreReturnValueSuggesterTest.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) 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(); + } }