-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct the type that appears in
new
for the generated toBuilder()
.
We want extensions to be able to subclass the nested `Builder` class that AutoValue generates. For example, if we are compiling `@AutoValue abstract class Foo`, and there is one extension, then AutoValue itself will generate `$AutoValue_Foo extends Foo` with a nested class `Builder` and the extension will generate `AutoValue_Foo extends $AutoValue_Foo`. That can contain its own `Builder` class extending `$AutoValue_Foo.Builder`, which will work correctly if `Foo` itself contains `new AutoValue_Foo.Builder()`. But before this change, the implementation of `$AutoValue_Foo.toBuilder()` contained just `new Builder(this)`, which therefore instantiates `$AutoValue_Foo.Builder` instead of `AutoValue_Foo.Builder`. The fix is for the generated `toBuilder()` to contain `new AutoValue_Foo.Builder(this)` instead. This change requires extensions to generate a "copy constructor" if they generate a `Builder` subclass and if [`BuilderContext.toBuilderMethods()`](https://javadoc.io/static/com.google.auto.value/auto-value/1.10.4/com/google/auto/value/extension/AutoValueExtension.BuilderContext.html#toBuilderMethods()) is not empty. RELNOTES=The generated `toBuilder()` method now says `new AutoValue_Foo.Builder(this)` rather than just `new Builder(this)`, to do the right thing if an extension generates its own subclass of `Builder`. PiperOrigin-RevId: 570406040
- Loading branch information
1 parent
63ee7b4
commit 324470b
Showing
6 changed files
with
45 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters