mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-11 12:19:00 +00:00
Merge pull request #2201 from middagj/clone-type
Clone type to correctly set annotated type on constructor, getter and setter
This commit is contained in:
5 files changed
+7
-3
No files matched your search
@@ -9,6 +9,7 @@ Dave Brosius <dbrosius@mebigfatguy.com>
|
||||
Dawid Rusin <dawidrusin90@gmail.com>
|
||||
Emil Lundberg <emil@yubico.com>
|
||||
Enrique da Costa Cambio <enrique.dacostacambio@gmail.com>
|
||||
Jacob Middag <jacob@gaddim.nl>
|
||||
Jan Matèrne <jhm@apache.org>
|
||||
Jan Rieke <it@janrieke.de>
|
||||
Jappe van der Hel <jappe.vanderhel@gmail.com>
|
||||
|
||||
@@ -13,6 +13,7 @@ Lombok Changelog
|
||||
* BUGFIX: Javac would generate the wrong equals and hashCode if a type-use annotation was put on an array type field [Issue #2165](https://github.com/rzwitserloot/lombok/issues/2165)
|
||||
* BUGFIX: Eclipse 2019-06 + JDK-12 compatibility + an `@Singular` builder entry would produce a cascade of error dialogs. [Issue #2169](https://github.com/rzwitserloot/lombok/issues/2169)
|
||||
* BUGFIX: Javac would throw a NullPointerException if the package-info.java did not contain a package declaration. [Issue #2184](https://github.com/rzwitserloot/lombok/issues/2184)
|
||||
* BUGFIX: Javac sets incorrect annotated type on constructor, getter and setter. [Issue #2189](https://github.com/rzwitserloot/lombok/issues/2189)
|
||||
* IMPROBABLE BREAKING CHANGE: Stricter validation of configuration keys dealing with identifiers and types (`lombok.log.fieldName`, `lombok.fieldNameConstants.innerTypeName`, `lombok.copyableAnnotations`).
|
||||
* IMPROBABLE BREAKING CHANGE: The fields generated inside builders for fields with defaults (with `@Builder` on a class with fields marked `@Default`) now have `$value` as the name; direct manipulation of these fields is not advised because there is an associated `$set` variable that also needs to be taken into account. [Issue #2115](https://github.com/rzwitserloot/lombok/issues/2115)
|
||||
|
||||
|
||||
@@ -339,7 +339,8 @@ public class HandleConstructor {
|
||||
Name rawName = field.name;
|
||||
List<JCAnnotation> copyableAnnotations = findCopyableAnnotations(fieldNode);
|
||||
long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, typeNode.getContext());
|
||||
JCVariableDecl param = maker.VarDef(maker.Modifiers(flags, copyableAnnotations), fieldName, field.vartype, null);
|
||||
JCExpression pType = cloneType(fieldNode.getTreeMaker(), field.vartype, source.get(), source.getContext());
|
||||
JCVariableDecl param = maker.VarDef(maker.Modifiers(flags, copyableAnnotations), fieldName, pType, null);
|
||||
params.append(param);
|
||||
if (hasNonNullAnnotations(fieldNode)) {
|
||||
JCStatement nullCheck = generateNullCheck(maker, param, source);
|
||||
|
||||
@@ -225,7 +225,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
|
||||
JCVariableDecl fieldNode = (JCVariableDecl) field.get();
|
||||
|
||||
// Remember the type; lazy will change it
|
||||
JCExpression methodType = copyType(treeMaker, fieldNode);
|
||||
JCExpression methodType = cloneType(treeMaker, copyType(treeMaker, fieldNode), source, field.getContext());
|
||||
// Generate the methodName; lazy will change the field type
|
||||
Name methodName = field.toName(toGetterName(field));
|
||||
|
||||
|
||||
@@ -242,7 +242,8 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> {
|
||||
List<JCAnnotation> annsOnParam = copyAnnotations(onParam).appendList(copyableAnnotations);
|
||||
|
||||
long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, field.getContext());
|
||||
JCVariableDecl param = treeMaker.VarDef(treeMaker.Modifiers(flags, annsOnParam), paramName, fieldDecl.vartype, null);
|
||||
JCExpression pType = cloneType(treeMaker, fieldDecl.vartype, source.get(), source.getContext());
|
||||
JCVariableDecl param = treeMaker.VarDef(treeMaker.Modifiers(flags, annsOnParam), paramName, pType, null);
|
||||
|
||||
if (!hasNonNullAnnotations(field) && !hasNonNullAnnotations(field, onParam)) {
|
||||
statements.append(treeMaker.Exec(assign));
|
||||
|
||||
Reference in new issue
Block a user