diff --git a/AUTHORS b/AUTHORS index bbbebb7cd7..e78064c93c 100755 --- a/AUTHORS +++ b/AUTHORS @@ -29,6 +29,7 @@ Maarten Mulders Mark Haynes Mart Hagenaars Mateusz Matela +Mat Jaggard Martin O'Connor <38929043+martinoconnor@users.noreply.github.com> Michael Dardis Michael Ernst diff --git a/src/core/lombok/eclipse/handlers/HandleGetter.java b/src/core/lombok/eclipse/handlers/HandleGetter.java index 2d8b112f47..b6986c9aab 100644 --- a/src/core/lombok/eclipse/handlers/HandleGetter.java +++ b/src/core/lombok/eclipse/handlers/HandleGetter.java @@ -82,7 +82,7 @@ @Provides public class HandleGetter extends EclipseAnnotationHandler { private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY = new Annotation[0]; - private static final String GETTER_NODE_NOT_SUPPORTED_ERR = "@Getter is only supported on a class, an enum, or a field."; + private static final String GETTER_NODE_NOT_SUPPORTED_ERR = "@Getter is only supported on a class, a record, an enum, or a field."; public boolean generateGetterForType(EclipseNode typeNode, EclipseNode pos, AccessLevel level, boolean checkForTypeLevelGetter, List onMethod) { if (checkForTypeLevelGetter) { @@ -92,7 +92,7 @@ public boolean generateGetterForType(EclipseNode typeNode, EclipseNode pos, Acce } } - if (!isClassOrEnum(typeNode)) { + if (!isClassEnumOrRecord(typeNode)) { pos.addError(GETTER_NODE_NOT_SUPPORTED_ERR); return false; } diff --git a/src/core/lombok/javac/handlers/HandleGetter.java b/src/core/lombok/javac/handlers/HandleGetter.java index 153a220134..fdc1106f32 100644 --- a/src/core/lombok/javac/handlers/HandleGetter.java +++ b/src/core/lombok/javac/handlers/HandleGetter.java @@ -71,7 +71,7 @@ */ @Provides public class HandleGetter extends JavacAnnotationHandler { - private static final String GETTER_NODE_NOT_SUPPORTED_ERR = "@Getter is only supported on a class, an enum, or a field."; + private static final String GETTER_NODE_NOT_SUPPORTED_ERR = "@Getter is only supported on a class, a record, an enum, or a field."; public void generateGetterForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level, boolean checkForTypeLevelGetter, List onMethod) { if (checkForTypeLevelGetter) { @@ -81,7 +81,7 @@ public void generateGetterForType(JavacNode typeNode, JavacNode errorNode, Acces } } - if (!isClassOrEnum(typeNode)) { + if (!isClassEnumOrRecord(typeNode)) { errorNode.addError(GETTER_NODE_NOT_SUPPORTED_ERR); return; } diff --git a/test/transform/resource/after-delombok/GetterOnRecord.java b/test/transform/resource/after-delombok/GetterOnRecord.java index 6318a6cc18..217e72051a 100644 --- a/test/transform/resource/after-delombok/GetterOnRecord.java +++ b/test/transform/resource/after-delombok/GetterOnRecord.java @@ -1,3 +1,12 @@ // version 14: public record GetterOnRecord(String a, String b) { + @java.lang.SuppressWarnings("all") + public String getA() { + return this.a; + } + + @java.lang.SuppressWarnings("all") + public String getB() { + return this.b; + } } diff --git a/test/transform/resource/after-ecj/GetterOnRecord.java b/test/transform/resource/after-ecj/GetterOnRecord.java index 735f0c80fb..d6e0aeddbe 100644 --- a/test/transform/resource/after-ecj/GetterOnRecord.java +++ b/test/transform/resource/after-ecj/GetterOnRecord.java @@ -3,4 +3,11 @@ public @Getter record GetterOnRecord(String a, String b) { /* Implicit */ private final String a; /* Implicit */ private final String b; + + public @java.lang.SuppressWarnings("all") String getA() { + return this.a; + } + public @java.lang.SuppressWarnings("all") String getB() { + return this.b; + } } diff --git a/test/transform/resource/messages-delombok/GetterOnRecord.java.messages b/test/transform/resource/messages-delombok/GetterOnRecord.java.messages deleted file mode 100644 index 0830c58559..0000000000 --- a/test/transform/resource/messages-delombok/GetterOnRecord.java.messages +++ /dev/null @@ -1 +0,0 @@ -5 @Getter is only supported on a class, an enum, or a field. diff --git a/test/transform/resource/messages-ecj/GetterOnRecord.java.messages b/test/transform/resource/messages-ecj/GetterOnRecord.java.messages deleted file mode 100644 index 0830c58559..0000000000 --- a/test/transform/resource/messages-ecj/GetterOnRecord.java.messages +++ /dev/null @@ -1 +0,0 @@ -5 @Getter is only supported on a class, an enum, or a field.