diff --git a/src/core/lombok/core/LombokNode.java b/src/core/lombok/core/LombokNode.java
index abfc66a6..34273a86 100644
--- a/src/core/lombok/core/LombokNode.java
+++ b/src/core/lombok/core/LombokNode.java
@@ -160,17 +160,15 @@ public abstract class LombokNode, L extends LombokNode fields = new ArrayList();
for (L potentialField : type.down()) {
if (potentialField.getKind() != Kind.FIELD) continue;
- if (fieldContainsAnnotation(potentialField.get(), get())) fields.add(potentialField);
+ for (L child : potentialField.down()) {
+ if (child.getKind() != Kind.ANNOTATION) continue;
+ if (child.get() == get()) fields.add(potentialField);
+ }
}
return fields;
}
- /**
- * Return {@code true} if the annotation is attached to the field.
- */
- protected abstract boolean fieldContainsAnnotation(N field, N annotation);
-
/**
* Returns the direct parent node in the AST tree of this node. For example, a local variable declaration's
* direct parent can be e.g. an If block, but its {@code up()} {@code LombokNode} is the {@code Method} that contains it.
diff --git a/src/core/lombok/eclipse/EclipseNode.java b/src/core/lombok/eclipse/EclipseNode.java
index 12e9ccdb..361a8d42 100644
--- a/src/core/lombok/eclipse/EclipseNode.java
+++ b/src/core/lombok/eclipse/EclipseNode.java
@@ -143,16 +143,6 @@ public class EclipseNode extends lombok.core.LombokNode {
switch (node.getKind()) {
case FIELD:
- Set fields = new LinkedHashSet();
- fields.add(node);
- fields.addAll(annotationNode.upFromAnnotationToFields());
- createWithByForFields(level, fields, annotationNode, true, onMethod);
+ createWithByForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, true, onMethod);
break;
case TYPE:
if (!onMethod.isEmpty()) {
diff --git a/src/core/lombok/javac/JavacNode.java b/src/core/lombok/javac/JavacNode.java
index 3de3f38b..e648cd51 100644
--- a/src/core/lombok/javac/JavacNode.java
+++ b/src/core/lombok/javac/JavacNode.java
@@ -186,16 +186,6 @@ public class JavacNode extends lombok.core.LombokNode transformer) {
return new WithByOnRecord(transformer.apply(this.a), this.b);
}
+
+ @java.lang.SuppressWarnings("all")
+ public WithByOnRecord withBBy(final java.util.function.Function super String, ? extends String> transformer) {
+ return new WithByOnRecord(this.a, transformer.apply(this.b));
+ }
}
diff --git a/test/transform/resource/after-delombok/WithByOnRecordComponent.java b/test/transform/resource/after-delombok/WithByOnRecordComponent.java
new file mode 100644
index 00000000..5af50625
--- /dev/null
+++ b/test/transform/resource/after-delombok/WithByOnRecordComponent.java
@@ -0,0 +1,6 @@
+record WithByOnRecordComponent(String a, String b) {
+ @java.lang.SuppressWarnings("all")
+ public WithByOnRecordComponent withABy(final java.util.function.Function super String, ? extends String> transformer) {
+ return new WithByOnRecordComponent(transformer.apply(this.a), this.b);
+ }
+}
diff --git a/test/transform/resource/after-delombok/WithOnRecordComponent.java b/test/transform/resource/after-delombok/WithOnRecordComponent.java
new file mode 100644
index 00000000..a5f4ec36
--- /dev/null
+++ b/test/transform/resource/after-delombok/WithOnRecordComponent.java
@@ -0,0 +1,6 @@
+record WithOnRecordComponent(String a, String b) {
+ @java.lang.SuppressWarnings("all")
+ public WithOnRecordComponent withA(final String a) {
+ return this.a == a ? this : new WithOnRecordComponent(a, this.b);
+ }
+}
diff --git a/test/transform/resource/after-ecj/WithByOnRecord.java b/test/transform/resource/after-ecj/WithByOnRecord.java
index 9048c9f4..c40841c8 100644
--- a/test/transform/resource/after-ecj/WithByOnRecord.java
+++ b/test/transform/resource/after-ecj/WithByOnRecord.java
@@ -1,8 +1,8 @@
import lombok.experimental.WithBy;
-record WithByOnRecord(String a, String b) {
+@WithBy record WithByOnRecord(String a, String b) {
/* Implicit */ private final String a;
/* Implicit */ private final String b;
- public WithByOnRecord( String a, String b) {
+ public WithByOnRecord(String a, String b) {
super();
.a = a;
.b = b;
@@ -10,4 +10,7 @@ record WithByOnRecord(String a, String b) {
public @java.lang.SuppressWarnings("all") WithByOnRecord withABy(final java.util.function.Function super String, ? extends String> transformer) {
return new WithByOnRecord(transformer.apply(this.a), this.b);
}
+ public @java.lang.SuppressWarnings("all") WithByOnRecord withBBy(final java.util.function.Function super String, ? extends String> transformer) {
+ return new WithByOnRecord(this.a, transformer.apply(this.b));
+ }
}
diff --git a/test/transform/resource/after-ecj/WithByOnRecordComponent.java b/test/transform/resource/after-ecj/WithByOnRecordComponent.java
new file mode 100644
index 00000000..19fe508c
--- /dev/null
+++ b/test/transform/resource/after-ecj/WithByOnRecordComponent.java
@@ -0,0 +1,13 @@
+import lombok.experimental.WithBy;
+record WithByOnRecordComponent(String a, String b) {
+/* Implicit */ private final String a;
+/* Implicit */ private final String b;
+ public WithByOnRecordComponent( String a, String b) {
+ super();
+ .a = a;
+ .b = b;
+ }
+ public @java.lang.SuppressWarnings("all") WithByOnRecordComponent withABy(final java.util.function.Function super String, ? extends String> transformer) {
+ return new WithByOnRecordComponent(transformer.apply(this.a), this.b);
+ }
+}
diff --git a/test/transform/resource/after-ecj/WithOnRecordComponent.java b/test/transform/resource/after-ecj/WithOnRecordComponent.java
new file mode 100644
index 00000000..42028f81
--- /dev/null
+++ b/test/transform/resource/after-ecj/WithOnRecordComponent.java
@@ -0,0 +1,13 @@
+import lombok.With;
+record WithOnRecordComponent(String a, String b) {
+/* Implicit */ private final String a;
+/* Implicit */ private final String b;
+ public WithOnRecordComponent( String a, String b) {
+ super();
+ .a = a;
+ .b = b;
+ }
+ public @java.lang.SuppressWarnings("all") WithOnRecordComponent withA(final String a) {
+ return ((this.a == a) ? this : new WithOnRecordComponent(a, this.b));
+ }
+}
diff --git a/test/transform/resource/before/WithByOnRecord.java b/test/transform/resource/before/WithByOnRecord.java
index 98cbff9b..6c7b8e2d 100644
--- a/test/transform/resource/before/WithByOnRecord.java
+++ b/test/transform/resource/before/WithByOnRecord.java
@@ -2,5 +2,6 @@
import lombok.experimental.WithBy;
-record WithByOnRecord(@WithBy String a, String b) {
+@WithBy
+record WithByOnRecord(String a, String b) {
}
\ No newline at end of file
diff --git a/test/transform/resource/before/WithByOnRecordComponent.java b/test/transform/resource/before/WithByOnRecordComponent.java
new file mode 100644
index 00000000..7e0f0f19
--- /dev/null
+++ b/test/transform/resource/before/WithByOnRecordComponent.java
@@ -0,0 +1,6 @@
+// version 14:
+
+import lombok.experimental.WithBy;
+
+record WithByOnRecordComponent(@WithBy String a, String b) {
+}
\ No newline at end of file
diff --git a/test/transform/resource/before/WithOnRecordComponent.java b/test/transform/resource/before/WithOnRecordComponent.java
new file mode 100644
index 00000000..6f827851
--- /dev/null
+++ b/test/transform/resource/before/WithOnRecordComponent.java
@@ -0,0 +1,6 @@
+// version 14:
+
+import lombok.With;
+
+record WithOnRecordComponent(@With String a, String b) {
+}
\ No newline at end of file