Skip to content

Commit

Permalink
[fixes #3427] Remove javac support for getter on enum members
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawi01 committed Aug 31, 2023
1 parent 000ce6d commit da00406
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 2 deletions.
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.

0 comments on commit da00406

Please sign in to comment.