Skip to content

Commit

Permalink
Really produce only a warning for setters with boxed primitive types …
Browse files Browse the repository at this point in the history
…for primitive properties.

We'd attempted this in cl/659352853, but we ended up reporting a warning and then failing with an error on a later step instead.

With the new test, we see an error until we make the prod change that I've included:

```
Compilation produced the following diagnostics:
foo/bar/Baz.java:11: warning: [AutoValueUnnecessaryBoxing] property method foo.bar.Baz.blam() is primitive but parameter of setter method is not
    Builder blam(Integer x);
            ^
foo/bar/Baz.java:10: error: [AutoValueBuilderMissingMethod] Expected a method with this signature: foo.bar.Baz.Builder blam(int), or a blamBuilder() method
  public interface Builder {
         ^
```

RELNOTES=n/a
PiperOrigin-RevId: 670953681
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Sep 4, 2024
1 parent edae679 commit 132a1a9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@ && originalPropertyType(propertyElement).getKind().isPrimitive()) {
"[%sUnnecessaryBoxing] %s is primitive but parameter of setter method is not",
autoWhat(),
propertyString(propertyElement));
return Optional.empty();
}
return Optional.of(Copier.IDENTITY);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4031,6 +4031,7 @@ public void autoValueBuilderNullableSetterPrimitiveGetter() {
javac()
.withProcessors(new AutoValueProcessor(), new AutoValueBuilderProcessor())
.compile(javaFileObject);
assertThat(compilation).succeeded();
assertThat(compilation)
.hadWarningContaining(
"property method foo.bar.Baz.blam() is primitive but parameter of setter method is not")
Expand Down

0 comments on commit 132a1a9

Please sign in to comment.