aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Rieke <rieke@subshell.com>2021-07-21 13:54:54 +0200
committerRoel Spilker <r.spilker@gmail.com>2022-01-07 21:10:19 +0100
commit9be867ef03b77e0455a45d22e4a8cd7c5fa9af61 (patch)
tree3e3f5787998557294130fec4624bd00c9b89d039
parentaa281e617269d3885b6e793fd0e699c638121318 (diff)
downloadlombok-9be867ef03b77e0455a45d22e4a8cd7c5fa9af61.tar.gz
lombok-9be867ef03b77e0455a45d22e4a8cd7c5fa9af61.tar.bz2
lombok-9be867ef03b77e0455a45d22e4a8cd7c5fa9af61.zip
[fixes #2908] don't generate checkerframework's @NotCalledMethods
-rw-r--r--src/core/lombok/core/configuration/CheckerFrameworkVersion.java1
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleBuilder.java13
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSuperBuilder.java1
-rw-r--r--src/core/lombok/javac/handlers/HandleBuilder.java10
-rw-r--r--src/core/lombok/javac/handlers/HandleSuperBuilder.java10
-rw-r--r--test/stubs/org/checkerframework/checker/calledmethods/qual/NotCalledMethods.java17
-rw-r--r--test/transform/resource/after-delombok/CheckerFrameworkBuilder.java6
-rw-r--r--test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java10
-rw-r--r--test/transform/resource/after-ecj/CheckerFrameworkBuilder.java6
-rw-r--r--test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java10
10 files changed, 18 insertions, 66 deletions
diff --git a/src/core/lombok/core/configuration/CheckerFrameworkVersion.java b/src/core/lombok/core/configuration/CheckerFrameworkVersion.java
index c37ba91d..684302d8 100644
--- a/src/core/lombok/core/configuration/CheckerFrameworkVersion.java
+++ b/src/core/lombok/core/configuration/CheckerFrameworkVersion.java
@@ -33,7 +33,6 @@ public final class CheckerFrameworkVersion implements ConfigurationValueType {
public static final String NAME__PURE = "org.checkerframework.dataflow.qual.Pure";
public static final String NAME__UNIQUE = "org.checkerframework.common.aliasing.qual.Unique";
public static final String NAME__RETURNS_RECEIVER = "org.checkerframework.common.returnsreceiver.qual.This";
- public static final String NAME__NOT_CALLED = "org.checkerframework.checker.calledmethods.qual.NotCalledMethods";
public static final String NAME__CALLED = "org.checkerframework.checker.calledmethods.qual.CalledMethods";
public static final CheckerFrameworkVersion NONE = new CheckerFrameworkVersion(0);
diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java
index 2bfe1e8b..a2dd5057 100755
--- a/src/core/lombok/eclipse/handlers/HandleBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java
@@ -767,18 +767,6 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
return decl;
}
- static Receiver generateNotCalledReceiver(BuilderJob job, String setterName) {
- char[][] nameNotCalled = fromQualifiedName(CheckerFrameworkVersion.NAME__NOT_CALLED);
- SingleMemberAnnotation ann = new SingleMemberAnnotation(new QualifiedTypeReference(nameNotCalled, poss(job.source, nameNotCalled.length)), job.source.sourceStart);
- ann.memberValue = new StringLiteral(setterName.toCharArray(), 0, 0, 0);
-
- TypeReference typeReference = job.createBuilderTypeReference();
- int trLen = typeReference.getTypeName().length;
- typeReference.annotations = new Annotation[trLen][];
- typeReference.annotations[trLen - 1] = new Annotation[] {ann};
- return new Receiver(new char[] { 't', 'h', 'i', 's' }, 0, typeReference, null, 0);
- }
-
static Receiver generateBuildReceiver(BuilderJob job) {
if (!job.checkerFramework.generateCalledMethods()) return null;
@@ -1050,7 +1038,6 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
ASTNode source = job.sourceNode.get();
MethodDeclaration setter = HandleSetter.createSetter(td, deprecate, fieldNode, setterName, bfd.name, bfd.nameOfSetFlag, job.oldChain, toEclipseModifier(job.accessInners),
job.sourceNode, methodAnnsList, bfd.annotations != null ? Arrays.asList(copyAnnotations(source, bfd.annotations)) : Collections.<Annotation>emptyList());
- if (job.checkerFramework.generateCalledMethods()) setter.receiver = generateNotCalledReceiver(job, setterName);
if (job.sourceNode.up().getKind() == Kind.METHOD) {
copyJavadocFromParam(bfd.originalFieldNode.up(), setter, td, bfd.name.toString());
} else {
diff --git a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
index 26b62cbf..96be13b8 100644
--- a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
@@ -1019,7 +1019,6 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
}
MethodDeclaration setter = HandleSetter.createSetter(td, deprecate, fieldNode, setterName, paramName, nameOfSetFlag, returnType, returnStatement, ClassFileConstants.AccPublic,
job.sourceNode, methodAnnsList, annosOnParam != null ? Arrays.asList(copyAnnotations(job.source, annosOnParam)) : Collections.<Annotation>emptyList());
- if (job.checkerFramework.generateCalledMethods()) setter.receiver = generateNotCalledReceiver(job, setterName);
injectMethod(job.builderType, setter);
}
diff --git a/src/core/lombok/javac/handlers/HandleBuilder.java b/src/core/lombok/javac/handlers/HandleBuilder.java
index 7f32001b..854c8524 100644
--- a/src/core/lombok/javac/handlers/HandleBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleBuilder.java
@@ -922,15 +922,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
JavacTreeMaker maker = fieldNode.getTreeMaker();
List<JCAnnotation> methodAnns = JavacHandlerUtil.findCopyableToSetterAnnotations(bfd.originalFieldNode);
- JCMethodDecl newMethod = null;
- if (job.checkerFramework.generateCalledMethods() && maker.hasMethodDefWithRecvParam()) {
- JCAnnotation ncAnno = maker.Annotation(genTypeRef(job.sourceNode, CheckerFrameworkVersion.NAME__NOT_CALLED), List.<JCExpression>of(maker.Literal(setterName.toString())));
- JCClassDecl builderTypeNode = (JCClassDecl) job.builderType.get();
- JCExpression selfType = namePlusTypeParamsToTypeReference(maker, job.builderType, builderTypeNode.typarams, List.<JCAnnotation>of(ncAnno));
- JCVariableDecl recv = maker.VarDef(maker.Modifiers(Flags.PARAMETER, List.<JCAnnotation>nil()), job.builderType.toName("this"), selfType, null);
- newMethod = HandleSetter.createSetterWithRecv(toJavacModifier(job.accessInners), deprecate, fieldNode, maker, setterName, bfd.name, bfd.nameOfSetFlag, job.oldChain, job.sourceNode, methodAnns, bfd.annotations, recv);
- }
- if (newMethod == null) newMethod = HandleSetter.createSetter(toJavacModifier(job.accessInners), deprecate, fieldNode, maker, setterName, bfd.name, bfd.nameOfSetFlag, job.oldChain, job.sourceNode, methodAnns, bfd.annotations);
+ JCMethodDecl newMethod = HandleSetter.createSetter(toJavacModifier(job.accessInners), deprecate, fieldNode, maker, setterName, bfd.name, bfd.nameOfSetFlag, job.oldChain, job.sourceNode, methodAnns, bfd.annotations);
recursiveSetGeneratedBy(newMethod, job.sourceNode);
if (job.sourceNode.up().getKind() == Kind.METHOD) {
copyJavadocFromParam(bfd.originalFieldNode.up(), newMethod, bfd.name.toString());
diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilder.java b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
index de8163dd..be579822 100644
--- a/src/core/lombok/javac/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
@@ -961,15 +961,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
JavacTreeMaker maker = fieldNode.getTreeMaker();
List<JCAnnotation> methodAnns = JavacHandlerUtil.findCopyableToSetterAnnotations(originalFieldNode);
- JCMethodDecl newMethod = null;
- if (job.checkerFramework.generateCalledMethods() && maker.hasMethodDefWithRecvParam()) {
- JCAnnotation ncAnno = maker.Annotation(genTypeRef(job.sourceNode, CheckerFrameworkVersion.NAME__NOT_CALLED), List.<JCExpression>of(maker.Literal(setterName.toString())));
- JCClassDecl builderTypeNode = (JCClassDecl) job.builderType.get();
- JCExpression selfType = namePlusTypeParamsToTypeReference(maker, job.builderType, builderTypeNode.typarams, List.<JCAnnotation>of(ncAnno));
- JCVariableDecl recv = maker.VarDef(maker.Modifiers(0L, List.<JCAnnotation>nil()), job.toName("this"), selfType, null);
- newMethod = HandleSetter.createSetterWithRecv(Flags.PUBLIC, deprecate, fieldNode, maker, setterName, paramName, nameOfSetFlag, returnType, returnStatement, job.sourceNode, methodAnns, annosOnParam, recv);
- }
- if (newMethod == null) newMethod = HandleSetter.createSetter(Flags.PUBLIC, deprecate, fieldNode, maker, setterName, paramName, nameOfSetFlag, returnType, returnStatement, job.sourceNode, methodAnns, annosOnParam);
+ JCMethodDecl newMethod = HandleSetter.createSetter(Flags.PUBLIC, deprecate, fieldNode, maker, setterName, paramName, nameOfSetFlag, returnType, returnStatement, job.sourceNode, methodAnns, annosOnParam);
if (job.checkerFramework.generateReturnsReceiver()) {
List<JCAnnotation> annotations = newMethod.mods.annotations;
if (annotations == null) annotations = List.nil();
diff --git a/test/stubs/org/checkerframework/checker/calledmethods/qual/NotCalledMethods.java b/test/stubs/org/checkerframework/checker/calledmethods/qual/NotCalledMethods.java
deleted file mode 100644
index 7a9ef37c..00000000
--- a/test/stubs/org/checkerframework/checker/calledmethods/qual/NotCalledMethods.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.checkerframework.checker.calledmethods.qual;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
-public @interface NotCalledMethods {
- /**
- * Methods that have been called, on any expression whose type is annotated.
- *
- * @return methods that have been called
- */
- public String[] value() default {};
-} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/CheckerFrameworkBuilder.java b/test/transform/resource/after-delombok/CheckerFrameworkBuilder.java
index 99272bd5..8c9197e2 100644
--- a/test/transform/resource/after-delombok/CheckerFrameworkBuilder.java
+++ b/test/transform/resource/after-delombok/CheckerFrameworkBuilder.java
@@ -36,7 +36,7 @@ class CheckerFrameworkBuilder {
*/
@org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
- public CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder x(CheckerFrameworkBuilder.@org.checkerframework.checker.calledmethods.qual.NotCalledMethods("x") CheckerFrameworkBuilderBuilder this, final int x) {
+ public CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder x(final int x) {
this.x$value = x;
x$set = true;
return this;
@@ -46,7 +46,7 @@ class CheckerFrameworkBuilder {
*/
@org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
- public CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder y(CheckerFrameworkBuilder.@org.checkerframework.checker.calledmethods.qual.NotCalledMethods("y") CheckerFrameworkBuilderBuilder this, final int y) {
+ public CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder y(final int y) {
this.y = y;
return this;
}
@@ -55,7 +55,7 @@ class CheckerFrameworkBuilder {
*/
@org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
- public CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder z(CheckerFrameworkBuilder.@org.checkerframework.checker.calledmethods.qual.NotCalledMethods("z") CheckerFrameworkBuilderBuilder this, final int z) {
+ public CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder z(final int z) {
this.z = z;
return this;
}
diff --git a/test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java b/test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java
index 8dcdaf10..9beaef1f 100644
--- a/test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java
+++ b/test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java
@@ -34,7 +34,7 @@ class CheckerFrameworkSuperBuilder {
*/
@org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
- public B x(CheckerFrameworkSuperBuilder.Parent.@org.checkerframework.checker.calledmethods.qual.NotCalledMethods("x") ParentBuilder<C, B> this, final int x) {
+ public B x(final int x) {
this.x$value = x;
x$set = true;
return self();
@@ -44,7 +44,7 @@ class CheckerFrameworkSuperBuilder {
*/
@org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
- public B y(CheckerFrameworkSuperBuilder.Parent.@org.checkerframework.checker.calledmethods.qual.NotCalledMethods("y") ParentBuilder<C, B> this, final int y) {
+ public B y(final int y) {
this.y = y;
return self();
}
@@ -53,7 +53,7 @@ class CheckerFrameworkSuperBuilder {
*/
@org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
- public B z(CheckerFrameworkSuperBuilder.Parent.@org.checkerframework.checker.calledmethods.qual.NotCalledMethods("z") ParentBuilder<C, B> this, final int z) {
+ public B z(final int z) {
this.z = z;
return self();
}
@@ -161,7 +161,7 @@ class CheckerFrameworkSuperBuilder {
*/
@org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
- public B a(CheckerFrameworkSuperBuilder.ZChild.@org.checkerframework.checker.calledmethods.qual.NotCalledMethods("a") ZChildBuilder<C, B> this, final int a) {
+ public B a(final int a) {
this.a$value = a;
a$set = true;
return self();
@@ -171,7 +171,7 @@ class CheckerFrameworkSuperBuilder {
*/
@org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
- public B b(CheckerFrameworkSuperBuilder.ZChild.@org.checkerframework.checker.calledmethods.qual.NotCalledMethods("b") ZChildBuilder<C, B> this, final int b) {
+ public B b(final int b) {
this.b = b;
return self();
}
diff --git a/test/transform/resource/after-ecj/CheckerFrameworkBuilder.java b/test/transform/resource/after-ecj/CheckerFrameworkBuilder.java
index d5ad0991..290ca381 100644
--- a/test/transform/resource/after-ecj/CheckerFrameworkBuilder.java
+++ b/test/transform/resource/after-ecj/CheckerFrameworkBuilder.java
@@ -14,7 +14,7 @@ import lombok.Singular;
/**
* @return {@code this}.
*/
- public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder x(CheckerFrameworkBuilder.@org.checkerframework.checker.calledmethods.qual.NotCalledMethods("x") CheckerFrameworkBuilderBuilder this, final int x) {
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder x(final int x) {
this.x$value = x;
x$set = true;
return this;
@@ -22,14 +22,14 @@ import lombok.Singular;
/**
* @return {@code this}.
*/
- public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder y(CheckerFrameworkBuilder.@org.checkerframework.checker.calledmethods.qual.NotCalledMethods("y") CheckerFrameworkBuilderBuilder this, final int y) {
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder y(final int y) {
this.y = y;
return this;
}
/**
* @return {@code this}.
*/
- public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder z(CheckerFrameworkBuilder.@org.checkerframework.checker.calledmethods.qual.NotCalledMethods("z") CheckerFrameworkBuilderBuilder this, final int z) {
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder z(final int z) {
this.z = z;
return this;
}
diff --git a/test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java b/test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java
index 6236fc72..340f04fe 100644
--- a/test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java
+++ b/test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java
@@ -16,7 +16,7 @@ class CheckerFrameworkSuperBuilder {
/**
* @return {@code this}.
*/
- public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") B x(CheckerFrameworkSuperBuilder.Parent. @org.checkerframework.checker.calledmethods.qual.NotCalledMethods("x") ParentBuilder<C, B> this, final int x) {
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") B x(final int x) {
this.x$value = x;
x$set = true;
return self();
@@ -24,14 +24,14 @@ class CheckerFrameworkSuperBuilder {
/**
* @return {@code this}.
*/
- public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") B y(CheckerFrameworkSuperBuilder.Parent. @org.checkerframework.checker.calledmethods.qual.NotCalledMethods("y") ParentBuilder<C, B> this, final int y) {
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") B y(final int y) {
this.y = y;
return self();
}
/**
* @return {@code this}.
*/
- public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") B z(CheckerFrameworkSuperBuilder.Parent. @org.checkerframework.checker.calledmethods.qual.NotCalledMethods("z") ParentBuilder<C, B> this, final int z) {
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") B z(final int z) {
this.z = z;
return self();
}
@@ -116,7 +116,7 @@ class CheckerFrameworkSuperBuilder {
/**
* @return {@code this}.
*/
- public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") B a(CheckerFrameworkSuperBuilder.ZChild. @org.checkerframework.checker.calledmethods.qual.NotCalledMethods("a") ZChildBuilder<C, B> this, final int a) {
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") B a(final int a) {
this.a$value = a;
a$set = true;
return self();
@@ -124,7 +124,7 @@ class CheckerFrameworkSuperBuilder {
/**
* @return {@code this}.
*/
- public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") B b(CheckerFrameworkSuperBuilder.ZChild. @org.checkerframework.checker.calledmethods.qual.NotCalledMethods("b") ZChildBuilder<C, B> this, final int b) {
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") B b(final int b) {
this.b = b;
return self();
}