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 --- .../javac/handlers/HandleEqualsAndHashCode.java | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/core/lombok/javac') diff --git a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java index 4bd1ce4b..da2db909 100644 --- a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java @@ -258,20 +258,23 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandlernil(), - 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