lombok-intellij-plugin icon indicating copy to clipboard operation
lombok-intellij-plugin copied to clipboard

Superbuilder default value delomboks to non-compilable code

Open MindWithCake opened this issue 3 years ago • 1 comments

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?

  1. Create a simple class, annotated with @SuperBuilder
  2. Add a field annotated with @Builder.Default and with a provided value
  3. Refactor -> delombok -> all lombok annotattions
  4. Generated code has a non-compilable constructor

Sample project

minimal-sample-project.zip

  • [x] Sample project provided
  • [x] I am able to reproduce this error on the sample project by following the steps described above

MindWithCake avatar Feb 21 '22 10:02 MindWithCake

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

irnbrux avatar Apr 25 '23 15:04 irnbrux