-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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] SuperBuilder not able to customize the Builder class when there is a property with @Singular annotation present #2701
Comments
Cannot reproduce in Eclipse and Maven. I suspect this is an IntelliJ plugin bug. |
Also, I vaguely recall that superbuilder will just intentionally error out on you if you attempt to write the class; that signature is incredibly complicated, asking lombok users to write it out is not something we intend to support. If it does not error out, I'm tempted to add it. (In other words, maybe the problem is that the intellij plugin fails to error out on this). |
However, HandleSuperBuilder:310 looks a bit fishy to me: I didn't have a closer look on that |
@janrieke no doubt - that was part of a gigantic refactor and I must have missed a beat. I'll fix this in a few moments. Other than that, I think the next step is to close this issue and tell @ahverdings to file with team intellij, specifically, that manually adding a buildertype that |
No, the example is perfectly fine. |
@janrieke You want to sign up for the notion that users end up manually writing this gigantic signature?
That's... unexpected. Okay. |
I implemented that primarily (before |
We are using lombok in a custom library used by 6 different projects. We are using custom methods in the parent class using @SuperBuilder for several cases:
These two breaking cases could be solved using another way around with heavy refactoring... But it's a breaking feature for us as the documentation of @SuperBuilder states these changes should be possible here: |
Thinking about it, manually writing this builder class header is indeed far from ideal (even if you'd c&p it from |
@janrieke Used vscode and gradle but error is the same: Lombok annotation handler class lombok.javac.handlers.HandleSuperBuilder failed on Parent.java: java.lang.NullPointerException (stacktrace is probably somewhere but im guessing its the same) Also tried using older versions and somewhere between version 1.18.12 and 1.18.14 a change was made that causes this NPE |
I'm pretty sure the line mentioned above causes the problem. However, I still cannot reproduce it. Could you check if your simple example really causes this issue? At least it's not compiling as is, because the A crashing example would be great so that we can derive a unit test from it. |
You're correct, the example (with corrected EqualsAndHashCode) is working. Which seemed weird to me so I did some further digging and found what causes the issue here. In my full piece of code I have many properties and for sake of the example left them out, thinking they would not cause the issue. My Parent class has a property annotated with updated Parent class example code (which fails):
None the less, is version 1.18.12 it's succesfull, from version 1.18.14 and up it fails. I will update the bug report. |
Is there any update on this, @rzwitserloot @janrieke ? Would love to see this fixed. :) |
[fixes #2701] fix NPE on customized SuperBuilder with Singular
When trying to extend the ParentBuilder the (de)lombok compiler throws the following error.
Example
When extending the Child SuperBuilder the following example is working.
But when trying to extend the Parent SuperBuilder and there is a property with @Singular annotation present the NPE is thrown.
Expected
What I'm trying to reach is that the custom method is available in all child (grandchild) builders. Extending the parent builder using
private static final class ParentBuilderImpl extends Parent.ParentBuilder<Parent, Parent.ParentBuilder> { ... }
will not throw the error but also will not make the custom method available in child builders (since its only available in ParentBuilderImpl where child builder do not extend from)The text was updated successfully, but these errors were encountered: