lombok-intellij-plugin
lombok-intellij-plugin copied to clipboard
Superbuilder default value delomboks to non-compilable code
Short description
if you give a @Builder.Default value to the field of a @SuperBuilder annotated class and try to delombok, the resulting code will use a non-existent b.field
call instead of handling the field$set
and field$value
fields.
Expected behavior
The code in the protected constructor should be something like this.field = b.field$set? b.field$value : /* the given default value*/
Version information
- IDEA Version: IntelliJ IDEA 2021.3.2, Build #IC-213.6777.52, Runtime version 11.0.13+7-b1751.25 amd64
- JDK Version: openjdk 11.0.13 2021-10-19
- OS Type & Version: Ubuntu 20.04.3 LTS, linux kernel 5.4.0-99-generic
- Lombok Plugin Version: bundled 213.6777.52
- Lombok Dependency Version: 1.18.22
Steps to reproduce
What steps do we need to take to reproduce this issue?
- Create a simple class, annotated with @SuperBuilder
- Add a field annotated with @Builder.Default and with a provided value
- Refactor -> delombok -> all lombok annotattions
- Generated code has a non-compilable constructor
Sample project
- [x] Sample project provided
- [x] I am able to reproduce this error on the sample project by following the steps described above
Hi,
I can confirm this. Basically the generated constructor in your class is invalid.
From
@SuperBuilder public abstract class Parent { @Builder.Default protected String name = "something"; }
you will end up with (delombok)
` public abstract class Parent { protected String name = "something";
protected Parent(Parent.ParentBuilder<?, ?> b) {
this.name = b.name; //<-- should be b.name$value instead
}
[... snip ...] `
Are there any plans to address this in near future?
Cheers Brian