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

@NoArgsConstructor complains about unassignable final field in IDE #1829

Closed
odrotbohm opened this issue Aug 22, 2018 · 2 comments
Closed

@NoArgsConstructor complains about unassignable final field in IDE #1829

odrotbohm opened this issue Aug 22, 2018 · 2 comments

Comments

@odrotbohm
Copy link

With Lombok 1.18.2, the following class produces a compiler error on the @NoArgsConstructor annotation stating the final field foo cannot be assigned:

@NoArgsConstructor(force = true)
class Sample {
  private final String foo = "bar";
}

On the command line the project compiles properly. Shouldn't the generated no-arg constructor simply skip the initialized, final field?

@janrieke
Copy link
Contributor

Can confirm that this bug only affects Eclipse. Likely cause: lombok.eclipse.handlers.HandleConstructor.fieldsNeedingExplicitDefaults() does not check for initializing expression, but lombok.javac.handlers.HandleConstructor.fieldsNeedingExplicitDefaults() does (line 401).

@odrotbohm
Copy link
Author

Lovely, thanks for debugging it that deeply, @janrieke!

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

No branches or pull requests

2 participants