diff options
author | Rawi01 <Rawi01@users.noreply.github.com> | 2021-01-31 14:33:19 +0100 |
---|---|---|
committer | Rawi01 <Rawi01@users.noreply.github.com> | 2021-01-31 14:33:38 +0100 |
commit | 191a8011ef5e8ae2a4446b9b357e121272526364 (patch) | |
tree | 0cafbd10414cb99507c7a69f9a882afcbfef898f /src/core/lombok/javac | |
parent | 3d3a4c322af4cf7f27679661efaa9dcd685165bb (diff) | |
download | lombok-191a8011ef5e8ae2a4446b9b357e121272526364.tar.gz lombok-191a8011ef5e8ae2a4446b9b357e121272526364.tar.bz2 lombok-191a8011ef5e8ae2a4446b9b357e121272526364.zip |
[fixes #1064] Only show super()-warning if lombok generates a method
Diffstat (limited to 'src/core/lombok/javac')
-rw-r--r-- | src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java index e76d701e..b17b0fdd 100644 --- a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java @@ -141,30 +141,6 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas boolean isDirectDescendantOfObject = isDirectDescendantOfObject(typeNode); - if (isDirectDescendantOfObject && callSuper) { - source.addError("Generating equals/hashCode with a supercall to java.lang.Object is pointless."); - return; - } - - if (implicitCallSuper && !isDirectDescendantOfObject) { - CallSuperType cst = typeNode.getAst().readConfiguration(ConfigurationKeys.EQUALS_AND_HASH_CODE_CALL_SUPER); - if (cst == null) cst = CallSuperType.WARN; - - switch (cst) { - default: - case WARN: - source.addWarning("Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type."); - callSuper = false; - break; - case SKIP: - callSuper = false; - break; - case CALL: - callSuper = true; - break; - } - } - boolean isFinal = (((JCClassDecl) typeNode.get()).mods.flags & Flags.FINAL) != 0; boolean needsCanEqual = !isFinal || !isDirectDescendantOfObject; MemberExistsResult equalsExists = methodExists("equals", typeNode, 1); @@ -193,6 +169,30 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas //fallthrough } + if (isDirectDescendantOfObject && callSuper) { + source.addError("Generating equals/hashCode with a supercall to java.lang.Object is pointless."); + return; + } + + if (implicitCallSuper && !isDirectDescendantOfObject) { + CallSuperType cst = typeNode.getAst().readConfiguration(ConfigurationKeys.EQUALS_AND_HASH_CODE_CALL_SUPER); + if (cst == null) cst = CallSuperType.WARN; + + switch (cst) { + default: + case WARN: + source.addWarning("Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type."); + callSuper = false; + break; + case SKIP: + callSuper = false; + break; + case CALL: + callSuper = true; + break; + } + } + JCMethodDecl equalsMethod = createEquals(typeNode, members, callSuper, fieldAccess, needsCanEqual, source, onParam); injectMethod(typeNode, equalsMethod); |