Skip to content
This repository has been archived by the owner on Nov 3, 2024. It is now read-only.

Builder ignores visibility of XArgsConstructor #919

Closed
mkeller-ergon opened this issue Sep 2, 2020 · 3 comments
Closed

Builder ignores visibility of XArgsConstructor #919

mkeller-ergon opened this issue Sep 2, 2020 · 3 comments
Assignees
Milestone

Comments

@mkeller-ergon
Copy link

Short description

This seems to be a regression as I never had this problem on IntelliJ 2020.1.x:
When a class has both a @builder and a @XArgsConstructor, the builder should not try to create a constructor but use the one from the explicit annotation. However, when combining them, intellij now sees the generated constructor as package-private instead of public.
The code works correctly when compiled using gradle, so it seems to be an IntelliJ plugin problem.

The doc of @builder is also clear about this:

If a member is annotated, it must be either a constructor or a method. If a class is annotated, then a private constructor is generated with all fields as arguments (as if @AllArgsConstructor(access = AccessLevel.PRIVATE) is present on the class), and it is as if this constructor has been annotated with @builder instead. Note that this constructor is only generated if you haven't written any constructors and also haven't added any explicit @XArgsConstructor annotations.

Expected behavior

The constructor should be generated with all rules of @XArgsConstructor, thus be public by default and honor the access property.

Version information

  • IDEA Version: IntelliJ IDEA 2020.2.1 (Ultimate Edition)
  • JDK Version: AdoptOpenJDK 11.0.8
  • OS Type & Version: Windows 10 Pro x64
  • Lombok Plugin Version: 0.30-EAP
  • Lombok Dependency Version: 1.18.12

Steps to reproduce

  1. Create the following class in IntelliJ:
@NoArgsConstructor
@Builder
public class Test {
}
  1. Watch it in the Structure view
  2. It says, it has 3 no-args constructors, all package-private instead of public.
  3. Adding an access=PUBLIC or any other level changes nothing
    image
@mplushnikov mplushnikov added the bug label Sep 5, 2020
@babhishek21
Copy link

Reproduced on IntelliJ IDEA 2020.2.2 (Ultimate Edition) on MacOS 10.15.16. Re-installing the plugin and invalidating IDEA cache helps resolves this until next IDEA restart.

@mkeller-ergon
Copy link
Author

Any news on this? This really hinders our development because we cannot reference the NoArgsConstructor directly anymore!

@mplushnikov mplushnikov added this to the 0.34 milestone Oct 29, 2020
@mplushnikov mplushnikov self-assigned this Oct 29, 2020
@mplushnikov
Copy link
Owner

@mkeller-ergon Fix for constructor generation should be available in the next release

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants