From b5ced8839652322f2262f4ad37fab63d8625add3 Mon Sep 17 00:00:00 2001 From: Kurt Alfred Kluever Date: Wed, 1 Feb 2023 09:55:06 -0800 Subject: [PATCH] Add a unit test for an `@Provides` annotated method where the return type is the same as the param type. PiperOrigin-RevId: 506345995 --- .../CanIgnoreReturnValueSuggesterTest.java | 17 +++++++++++++++++ 1 file changed, 17 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 b355a7f75d4..1239cf047bd 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 @@ -830,4 +830,21 @@ public void providesMethod_b267362954() { .expectUnchanged() .doTest(); } + + @Test + public void providesWithoutChangingType_b267463718() { + helper + .addInputLines( + "ExampleModule.java", + "package com.google.frobber;", + "public final class ExampleModule {", + " @com.google.inject.Provides", + " boolean provideEnableNewRiskAssignment(boolean enableNewRiskAssignment) {", + " return enableNewRiskAssignment;", + " }", + "}") + // we don't fire because @Provides is @Keep + .expectUnchanged() + .doTest(); + } }