Skip to content

Commit

Permalink
Verify that UnnecessaryBoxedVariable handles AutoValue factories
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 656498912
  • Loading branch information
cushon authored and Error Prone Team committed Jul 26, 2024
1 parent 3ad4e45 commit 40f5b21
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}

0 comments on commit 40f5b21

Please sign in to comment.