Skip to content

Commit

Permalink
Merge pull request projectlombok#3494 from Rawi01/enum-getter
Browse files Browse the repository at this point in the history
Remove javac support for getter on enum members
  • Loading branch information
rzwitserloot authored Sep 17, 2023
2 parents 6623e12 + da00406 commit 67cd7a6
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 67cd7a6

Please sign in to comment.