From 40f5b218307425192cc2d1dbf10f47f2e07038de Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Fri, 26 Jul 2024 12:52:02 -0700 Subject: [PATCH] Verify that UnnecessaryBoxedVariable handles AutoValue factories PiperOrigin-RevId: 656498912 --- .../UnnecessaryBoxedVariableTest.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/UnnecessaryBoxedVariableTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/UnnecessaryBoxedVariableTest.java index 0657fafe4c0..8d021b6f646 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/UnnecessaryBoxedVariableTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/UnnecessaryBoxedVariableTest.java @@ -16,6 +16,8 @@ package com.google.errorprone.bugpatterns; +import com.google.auto.value.processor.AutoValueProcessor; +import com.google.common.collect.ImmutableList; import com.google.errorprone.BugCheckerRefactoringTestHelper; import com.google.errorprone.CompilationTestHelper; import org.junit.Test; @@ -87,4 +89,23 @@ public void lambdaReturn() { "}") .doTest(); } + + @Test + public void positiveFactory() { + compilationTestHelper + .addSourceLines( + "Foo.java", + "import com.google.auto.value.AutoValue;", + "@AutoValue", + "abstract class Foo {", + " abstract int getFoo();", + " abstract boolean isBar();", + " // BUG: Diagnostic contains: int foo", + " static Foo create(Integer foo, Boolean bar) {", + " return new AutoValue_Foo(foo, bar);", + " }", + "}") + .setArgs(ImmutableList.of("-processor", AutoValueProcessor.class.getName())) + .doTest(); + } }