diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2018-11-01 16:43:25 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2018-11-01 16:43:25 +0100 |
commit | 4acda73319e95c4caf472ca47183af57a1bc9fd1 (patch) | |
tree | 89e33400026a091055262a8ce8a90a56e32b1d69 /src/core | |
parent | 2fd46a50b6125fd9f0e8177ffad5db8ee934fe34 (diff) | |
download | lombok-4acda73319e95c4caf472ca47183af57a1bc9fd1.tar.gz lombok-4acda73319e95c4caf472ca47183af57a1bc9fd1.tar.bz2 lombok-4acda73319e95c4caf472ca47183af57a1bc9fd1.zip |
[trivial] error out on mismatch between FieldNameConstants asEnum flag and actual handwritten type.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/lombok/eclipse/handlers/HandleFieldNameConstants.java | 8 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/HandleFieldNameConstants.java | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleFieldNameConstants.java b/src/core/lombok/eclipse/handlers/HandleFieldNameConstants.java index 91b7771b..9e81a068 100644 --- a/src/core/lombok/eclipse/handlers/HandleFieldNameConstants.java +++ b/src/core/lombok/eclipse/handlers/HandleFieldNameConstants.java @@ -132,8 +132,12 @@ public class HandleFieldNameConstants extends EclipseAnnotationHandler<FieldName genClinit = asEnum; } else { TypeDeclaration builderTypeDeclaration = (TypeDeclaration) fieldsType.get(); - if ((builderTypeDeclaration.modifiers & (ClassFileConstants.AccEnum | ClassFileConstants.AccStatic)) == 0) { - errorNode.addError("Existing " + innerTypeName + " must be declared as an 'enum' or a 'static class'."); + if (asEnum && (builderTypeDeclaration.modifiers & ClassFileConstants.AccEnum) == 0) { + errorNode.addError("Existing " + innerTypeName + " must be declared as an 'enum'."); + return; + } + if (!asEnum && (builderTypeDeclaration.modifiers & ClassFileConstants.AccStatic) == 0) { + errorNode.addError("Existing " + innerTypeName + " must be declared as a 'static class'."); return; } genConstr = constructorExists(fieldsType) == MemberExistsResult.NOT_EXISTS; diff --git a/src/core/lombok/javac/handlers/HandleFieldNameConstants.java b/src/core/lombok/javac/handlers/HandleFieldNameConstants.java index 163a82b3..4015df12 100644 --- a/src/core/lombok/javac/handlers/HandleFieldNameConstants.java +++ b/src/core/lombok/javac/handlers/HandleFieldNameConstants.java @@ -139,8 +139,12 @@ public class HandleFieldNameConstants extends JavacAnnotationHandler<FieldNameCo } else { JCClassDecl builderTypeDeclaration = (JCClassDecl) fieldsType.get(); long f = builderTypeDeclaration.getModifiers().flags; - if ((f & (Flags.STATIC | Flags.ENUM)) == 0) { - errorNode.addError("Existing " + innerTypeName + " must be declared as an 'enum' or a 'static class'."); + if (asEnum && (f & Flags.ENUM) == 0) { + errorNode.addError("Existing " + innerTypeName + " must be declared as an 'enum'."); + return; + } + if (!asEnum && (f & Flags.STATIC) == 0) { + errorNode.addError("Existing " + innerTypeName + " must be declared as a 'static class'."); return; } genConstr = constructorExists(fieldsType) == MemberExistsResult.NOT_EXISTS; |