aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorReinier Zwitserloot <r.zwitserloot@projectlombok.org>2023-01-12 01:48:01 +0100
committerGitHub <noreply@github.com>2023-01-12 01:48:01 +0100
commit3c9e4770b38de4ac3df51c696562b3ff212cba05 (patch)
treed33cf304e1e020138d2ed7f79040f82d2c15d1ea /src
parent9ad2846b5dc4c5adfaf8c9884dfdaf4648e681dd (diff)
parent5835e5d19fd4b22c88fbb8d304858786b060fe71 (diff)
downloadlombok-3c9e4770b38de4ac3df51c696562b3ff212cba05.tar.gz
lombok-3c9e4770b38de4ac3df51c696562b3ff212cba05.tar.bz2
lombok-3c9e4770b38de4ac3df51c696562b3ff212cba05.zip
Merge pull request #3262 from marc-guenther/extension-methods-for-interfaces
fixes #3259: allow @ExtensionMethod on interfaces
Diffstat (limited to 'src')
-rw-r--r--src/core/lombok/eclipse/handlers/HandleExtensionMethod.java4
-rw-r--r--src/core/lombok/javac/handlers/HandleExtensionMethod.java6
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java4
3 files changed, 9 insertions, 5 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleExtensionMethod.java b/src/core/lombok/eclipse/handlers/HandleExtensionMethod.java
index 5857780c..b84018c6 100644
--- a/src/core/lombok/eclipse/handlers/HandleExtensionMethod.java
+++ b/src/core/lombok/eclipse/handlers/HandleExtensionMethod.java
@@ -50,10 +50,10 @@ public class HandleExtensionMethod extends EclipseAnnotationHandler<ExtensionMet
int modifiers = typeDecl == null ? 0 : typeDecl.modifiers;
boolean notAClass = (modifiers &
- (ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation)) != 0;
+ (ClassFileConstants.AccAnnotation)) != 0;
if (typeDecl == null || notAClass) {
- annotationNode.addError("@ExtensionMethod is legal only on classes and enums.");
+ annotationNode.addError("@ExtensionMethod is legal only on classes and enums and interfaces.");
return;
}
diff --git a/src/core/lombok/javac/handlers/HandleExtensionMethod.java b/src/core/lombok/javac/handlers/HandleExtensionMethod.java
index dd565f72..98b000c2 100644
--- a/src/core/lombok/javac/handlers/HandleExtensionMethod.java
+++ b/src/core/lombok/javac/handlers/HandleExtensionMethod.java
@@ -73,10 +73,10 @@ public class HandleExtensionMethod extends JavacAnnotationHandler<ExtensionMetho
deleteAnnotationIfNeccessary(annotationNode, ExtensionMethod.class);
JavacNode typeNode = annotationNode.up();
- boolean isClassOrEnum = isClassOrEnum(typeNode);
+ boolean isClassOrEnumOrInterface = isClassOrEnumOrInterface(typeNode);
- if (!isClassOrEnum) {
- annotationNode.addError("@ExtensionMethod can only be used on a class or an enum");
+ if (!isClassOrEnumOrInterface) {
+ annotationNode.addError("@ExtensionMethod can only be used on a class or an enum or an interface");
return;
}
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index b17e34d8..9d153a72 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -2069,6 +2069,10 @@ public class JavacHandlerUtil {
return isClassAndDoesNotHaveFlags(typeNode, Flags.INTERFACE | Flags.ANNOTATION | RECORD);
}
+ public static boolean isClassOrEnumOrInterface(JavacNode typeNode) {
+ return isClassAndDoesNotHaveFlags(typeNode, Flags.ANNOTATION | RECORD);
+ }
+
/**
* Returns {@code true} if the provided node is an actual class, an enum or a record and not some other type declaration (so, not an annotation definition or interface).
*/