Description
Cannot use @SuperBuilder with nested Generic types. (With the latest release and edge-SNAPSHOT)
How to repeat
import lombok.experimental.SuperBuilder;
@SuperBuilder
public abstract class Generic<T extends Generic<?>> {}
import lombok.experimental.SuperBuilder;
@SuperBuilder
public abstract class NestedGeneric<T extends OtherGeneric<?>> extends Generic<NestedGeneric<? extends OtherGeneric<?>>> {}
public interface OtherGeneric<T> {}
...\Test\src\main\java\NestedGeneric.java:5: error: wrong number of type arguments; required 3
@SuperBuilder
^
If i replace this ... extend Generic<NestedGeneric<? extends otherGeneric<?>>> like ... extends Generic<NoGenericExtendsNestedGeneric> or not use nested generic types, it will be successfully builded.
Can confirm, but looking at the delombok output of the example, I must admit I don't know how the correct output should look like.
What have I done implementing this generics hell? ;)
Can confirm, but looking at the delombok output of the example, I must admit I don't know how the correct output should look like.
What have I done implementing this generics hell? ;)
It's only example :) But it's very close to my structure. I use Reactor project to share event from service, factory or other source. In common situation, passing a child type to a super type as generic parameter helps me confirm that the child inherits this super type and bounds the event type which can pass that child.
I did't use delombok, so I also don't know how to repair this behavior. More precisely: I could bound the type directly in the generic definition and pass it to the super type (It works). But it's makes me to pass the generic parameter manually to the super type.
Sorry for my english.
I think I figured out how it should look like and found the problem. Working on a fix.
Your English is good. No need to apologize even if it would be not so good: Most of the commenters here are not native speakers as well.
@rzwitserloot Will this be released soon? 1.18.12 does not contain this fix, or does it?
No, it's not in 1.18.12. You could try the current edge release.
1.18.12 was released in February. When can we expect a release that contains this fix?
Is this resolved? still see it in 1.18.16 and plugin: 0.34-2020.2.
Child.java:6
java: wrong number of type arguments; required 3
@SuperBuilder
public abstract class Parent<T> {
@NonNull
private final T fieldA;
}
@SuperBuilder
public abstract class Child<T> extends Parent {
private final String fieldB;
}
The type argument <T> is missing in your extends clause.
The type argument
<T>is missing in yourextendsclause.
Interesting, that worked. Now, the custom override does not work :( inside a SuperBuilder.
https://stackoverflow.com/questions/37968696/how-to-run-code-after-constructor-in-a-lombok-builder
That question is about regular @Builders. @SuperBuilder is very different. Please read the docs on customizing @SuperBuilder, especially the hint on using delombok. If that doesn't help, try searching StackOverflow (there a few qustions about customizing SuperBuilder). Create a new question if that doesn't solve your problem.
That question is about regular
@Builders.@SuperBuilderis very different. Please read the docs on customizing@SuperBuilder, especially the hint on usingdelombok. If that doesn't help, try searching StackOverflow (there a few qustions about customizingSuperBuilder). Create a new question if that doesn't solve your problem.
Makes sense.
Most helpful comment
1.18.12 was released in February. When can we expect a release that contains this fix?