fixes ...: allow @ExtensionMethod on interfaces

This commit is contained in:
Marc Guenther committed 2022-09-14 22:15:01 +02:00
1 parent 91a511bbb7
commit 5835e5d19f
3 files changed
+9 -5

No files matched your search

@@ -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;
}
@@ -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;
}
@@ -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).
*/