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

[BUG] Wrong number of type arguments; required 3 #2359

Closed
Bittuw opened this issue Feb 10, 2020 · 11 comments · Fixed by #2362
Closed

[BUG] Wrong number of type arguments; required 3 #2359

Bittuw opened this issue Feb 10, 2020 · 11 comments · Fixed by #2362

Comments

@Bittuw
Copy link

Bittuw commented Feb 10, 2020

Description
Cannot use @SuperBuilder with nested Generic types. (With the latest release and edge-SNAPSHOT)

How to repeat

Generic.java

import lombok.experimental.SuperBuilder;


@SuperBuilder
public abstract class Generic<T extends Generic<?>> {}

NestedGeneric.java

import lombok.experimental.SuperBuilder;


@SuperBuilder
public abstract class NestedGeneric<T extends OtherGeneric<?>> extends Generic<NestedGeneric<? extends OtherGeneric<?>>> {}

OtherGeneric.java

public interface OtherGeneric<T> {}

Exception desc:

...\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.

@janrieke
Copy link
Contributor

janrieke commented Feb 10, 2020

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? ;)

@Bittuw
Copy link
Author

Bittuw commented Feb 11, 2020

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.

@janrieke
Copy link
Contributor

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.

@silkentrance
Copy link

silkentrance commented Apr 1, 2020

@rzwitserloot Will this be released soon? 1.18.12 does not contain this fix, or does it?

@janrieke
Copy link
Contributor

janrieke commented Apr 1, 2020

No, it's not in 1.18.12. You could try the current edge release.

@JohnArrowwood
Copy link

1.18.12 was released in February. When can we expect a release that contains this fix?

@krishna81m
Copy link

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;

}

@janrieke
Copy link
Contributor

janrieke commented Mar 6, 2021

The type argument <T> is missing in your extends clause.

@krishna81m
Copy link

The type argument <T> is missing in your extends clause.

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

@janrieke
Copy link
Contributor

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.

@krishna81m
Copy link

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.

Makes sense.

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 a pull request may close this issue.

5 participants