From 045638ec1f79f68747f135061d2e026faa719642 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Mon, 6 Nov 2017 23:45:52 +0100 Subject: Generate correct hashCode when callSuper and no fields included. Fixes #1505 --- .../eclipse/handlers/HandleEqualsAndHashCode.java | 32 ++++++++++++---------- .../javac/handlers/HandleEqualsAndHashCode.java | 23 +++++++++------- 2 files changed, 31 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java index 37fa78ab..0d0f51db 100644 --- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java @@ -299,7 +299,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandlernil(), - maker.Select(maker.Ident(typeNode.toName("super")), typeNode.toName("hashCode")), - List.nil()); - statements.append(createResultCalculation(typeNode, callToSuper)); + /* int result = ... */ { + final JCExpression init; + if (callSuper) { + /* ... super.hashCode(); */ + init = maker.Apply(List.nil(), + maker.Select(maker.Ident(typeNode.toName("super")), typeNode.toName("hashCode")), + List.nil()); + } else { + /* ... 1; */ + init = maker.Literal(1); + } + statements.append(maker.VarDef(maker.Modifiers(0), resultName, maker.TypeIdent(CTC_INT), init)); } Name dollar = typeNode.toName("$"); -- cgit