diff options
author | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2019-08-22 23:27:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-22 23:27:10 +0200 |
commit | 383c00fa85c50555dbaf4d7aff493ef99e7a8e1a (patch) | |
tree | bfd83d64061f1606470e91ae24dc4c8693b10015 /src/core/lombok | |
parent | ba8fd3782819682b3f4081cb410b6d43055989b9 (diff) | |
parent | db19a9fd8320a0abf7a530e9e35639089ce77050 (diff) | |
download | lombok-383c00fa85c50555dbaf4d7aff493ef99e7a8e1a.tar.gz lombok-383c00fa85c50555dbaf4d7aff493ef99e7a8e1a.tar.bz2 lombok-383c00fa85c50555dbaf4d7aff493ef99e7a8e1a.zip |
Merge pull request #2201 from middagj/clone-type
Clone type to correctly set annotated type on constructor, getter and setter
Diffstat (limited to 'src/core/lombok')
-rw-r--r-- | src/core/lombok/javac/handlers/HandleConstructor.java | 3 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/HandleGetter.java | 2 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/HandleSetter.java | 3 |
3 files changed, 5 insertions, 3 deletions
diff --git a/src/core/lombok/javac/handlers/HandleConstructor.java b/src/core/lombok/javac/handlers/HandleConstructor.java index 9af124b5..4d7c61ad 100644 --- a/src/core/lombok/javac/handlers/HandleConstructor.java +++ b/src/core/lombok/javac/handlers/HandleConstructor.java @@ -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); diff --git a/src/core/lombok/javac/handlers/HandleGetter.java b/src/core/lombok/javac/handlers/HandleGetter.java index f4ac2584..681865df 100644 --- a/src/core/lombok/javac/handlers/HandleGetter.java +++ b/src/core/lombok/javac/handlers/HandleGetter.java @@ -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)); diff --git a/src/core/lombok/javac/handlers/HandleSetter.java b/src/core/lombok/javac/handlers/HandleSetter.java index 26820fe6..926e94d9 100644 --- a/src/core/lombok/javac/handlers/HandleSetter.java +++ b/src/core/lombok/javac/handlers/HandleSetter.java @@ -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)); |