Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix toBuilder generator with generics #1460

Merged

Conversation

rdesgroppes
Copy link
Contributor

@rdesgroppes rdesgroppes commented May 9, 2023

This is meant to resolve #1459 as follows:

   /**
    * Creates a builder for {@link ImmutableToBuilderClassicWithGenerics ImmutableToBuilderClassicWithGenerics}.prefilled
    * with attibute values of {@code this} instance to easily create modified copies.
    * @return A new ImmutableToBuilderClassicWithGenerics builder with attributes of {@code this} instance
    */
-  public ImmutableToBuilderClassicWithGenerics.Builder<T><T> toBuilder()
+  public ImmutableToBuilderClassicWithGenerics.Builder<T> toBuilder() {
     return ImmutableToBuilderClassicWithGenerics.<T>builder().from(this);
   }

(snippet comes from value-fixture/target/generated-sources/annotations/org/immutables/fixture/builder/ImmutableToBuilderClassicWithGenerics.java)

This is meant to resolve immutables#1459 as follows:
```diff
   /**
    * Creates a builder for {@link ImmutableToBuilderClassicWithGenerics ImmutableToBuilderClassicWithGenerics}.prefilled
    * with attibute values of {@code this} instance to easily create modified copies.
    * @return A new ImmutableToBuilderClassicWithGenerics builder with attributes of {@code this} instance
    */
-  public ImmutableToBuilderClassicWithGenerics.Builder<T><T> toBuilder()
+  public ImmutableToBuilderClassicWithGenerics.Builder<T> toBuilder() {
     return ImmutableToBuilderClassicWithGenerics.<T>builder().from(this);
   }
```
(snippet comes from
`value-fixture/target/generated-sources/annotations/org/immutables/fixture/builder/ImmutableToBuilderClassicWithGenerics.java`)
@rdesgroppes
Copy link
Contributor Author

@elucash questions I asked myself while working on this:

  1. is the remaining [type.typeBuilder.relative] fine? I don't see it used as return type for other builder method signatures...
  2. should I augment the existing ToBuilderMethod interface with a new entry point instead of creating an ad-hoc one? (ToBuilderClassicWithGenerics)

Thanks!

@elucash
Copy link
Member

elucash commented May 22, 2023

Yes, the change appears to be correct. typeBuilder and other similar accessors return an object with generic type parameters applied, it's the .typeBuilder.relativeRaw would leave generics out. Thank you for the PR!

@elucash elucash merged commit ca11af6 into immutables:master May 22, 2023
16 checks passed
@elucash elucash added this to the 2.9.4 milestone May 22, 2023
@rdesgroppes rdesgroppes deleted the fix-to-builder-generator-with-generics branch May 22, 2023 10:54
@rdesgroppes
Copy link
Contributor Author

Thanks again, @elucash. May we expect a release in the near future?

@elucash
Copy link
Member

elucash commented May 25, 2023

Should release soon, currently evaluating jakarta.* related change/configuration, which will also go into release. I dunno, about a week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generated toBuilder signature is incorrect with generics
2 participants