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

Remove javac support for getter on enum members #3494

Merged
merged 1 commit into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/lombok/eclipse/handlers/HandleGetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public void createGetterForFields(AccessLevel level, Collection<EclipseNode> fie
public void createGetterForField(AccessLevel level,
EclipseNode fieldNode, EclipseNode errorNode, ASTNode source, boolean whineIfExists, boolean lazy, List<Annotation> onMethod) {

if (fieldNode.getKind() != Kind.FIELD) {
if (fieldNode.getKind() != Kind.FIELD || fieldNode.isEnumMember()) {
errorNode.addError(GETTER_NODE_NOT_SUPPORTED_ERR);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/lombok/javac/handlers/HandleGetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public void createGetterForFields(AccessLevel level, Collection<JavacNode> field
public void createGetterForField(AccessLevel level,
JavacNode fieldNode, JavacNode source, boolean whineIfExists, boolean lazy, List<JCAnnotation> onMethod) {

if (fieldNode.getKind() != Kind.FIELD) {
if (fieldNode.getKind() != Kind.FIELD || fieldNode.isEnumMember()) {
source.addError(GETTER_NODE_NOT_SUPPORTED_ERR);
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
enum GetterEnumConstant {
ONE;
}
9 changes: 9 additions & 0 deletions test/transform/resource/after-ecj/GetterEnumConstant.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import lombok.Getter;
enum GetterEnumConstant {
@Getter ONE(),
<clinit>() {
}
GetterEnumConstant() {
super();
}
}
6 changes: 6 additions & 0 deletions test/transform/resource/before/GetterEnumConstant.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import lombok.Getter;

enum GetterEnumConstant {
@Getter
ONE;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4 @Getter is only supported on a class, an enum, or a field.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4 @Getter is only supported on a class, an enum, or a field.
Loading