From 3d0beec38d8d19e8c90df56d7f4297d1c5f332ee Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Tue, 29 Jan 2019 01:33:40 +0100 Subject: [fixes #2011] If you have a field named `build` or `toString`, and you generate a builder, that builder wouldn’t make the build or toString methods because it thinks the builder-setter methods it just generated that so happen to have that name indicate you don’t want lombok to do that. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit You really shouldn’t name any fields builder or toString, though. --- src/core/lombok/javac/handlers/HandleBuilder.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/core/lombok/javac/handlers/HandleBuilder.java') diff --git a/src/core/lombok/javac/handlers/HandleBuilder.java b/src/core/lombok/javac/handlers/HandleBuilder.java index 081123aa..c1e93547 100644 --- a/src/core/lombok/javac/handlers/HandleBuilder.java +++ b/src/core/lombok/javac/handlers/HandleBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2018 The Project Lombok Authors. + * Copyright (C) 2013-2019 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -405,11 +405,15 @@ public class HandleBuilder extends JavacAnnotationHandler { makeSetterMethodsForBuilder(builderType, bfd, annotationNode, fluent, chain); } - if (methodExists(buildMethodName, builderType, -1) == MemberExistsResult.NOT_EXISTS) { - JCMethodDecl md = generateBuildMethod(tdParent, isStatic, buildMethodName, nameOfBuilderMethod, returnType, builderFields, builderType, thrownExceptions, ast, addCleaning); - if (md != null) { - injectMethod(builderType, md); - recursiveSetGeneratedBy(md, ast, annotationNode.getContext()); + { + MemberExistsResult methodExists = methodExists(builderMethodName, builderType, -1); + if (methodExists == MemberExistsResult.EXISTS_BY_LOMBOK) methodExists = methodExists(buildMethodName, builderType, 0); + if (methodExists == MemberExistsResult.NOT_EXISTS) { + JCMethodDecl md = generateBuildMethod(tdParent, isStatic, buildMethodName, nameOfBuilderMethod, returnType, builderFields, builderType, thrownExceptions, ast, addCleaning); + if (md != null) { + injectMethod(builderType, md); + recursiveSetGeneratedBy(md, ast, annotationNode.getContext()); + } } } -- cgit