Supporting Generics on Classes Annotated with @SuperBuilder

40 views
Skip to first unread message

Nathaniel Troutman

unread,
Apr 2, 2024, 12:04:16 PMApr 2
to Project Lombok
I've run into an issue where using @SuperBuilder on a class with Generics fails if you try to customize the constructor that accepts the builder class.

For example this fails with the error `error: constructor Parent(ParentBuilder<T,?,?>) is already defined in class Parent`:

```
@SuperBuilder
public class Parent<T> {
  int field;

  protected Parent(ParentBuilder<T, ?, ?> b) {
    if (b.field == 0)
      throw new IllegalArgumentException("field must be != 0");
      this.field = b.field;
    }
}
```

I'm happy to contribute the fix as I already know where the bug is and done a quick POC. Is this something that would be beneficial?


Jan Rieke

unread,
Apr 3, 2024, 3:14:10 AMApr 3
to project...@googlegroups.com
Hi Nathaniel!

Yes, I consider this a bug. If the customization works for non-generic
classes, it should work for classes with type parameters, too.
I'll review the PR once you are finished.

Best regards
Jan
> --
> You received this message because you are subscribed to the Google
> Groups "Project Lombok" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to project-lombo...@googlegroups.com
> <mailto:project-lombo...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/project-lombok/c1c9366f-f112-4314-a548-49bb6180ccf5n%40googlegroups.com <https://groups.google.com/d/msgid/project-lombok/c1c9366f-f112-4314-a548-49bb6180ccf5n%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
subshell GmbH | Sitz: Hamburg, Amtsgericht Hamburg, HRB 74783 |
Geschäftsführung: Jan Boddin
Reply all
Reply to author
Forward
0 new messages