Skip to content

Commit

Permalink
Fix toMethod/toField if the type is null
Browse files Browse the repository at this point in the history
  • Loading branch information
I-Al-Istannen committed Aug 2, 2024
1 parent 66fedaf commit 99da5e2
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class CtRecordComponentImpl extends CtNamedElementImpl implements CtRecor
public CtMethod<?> toMethod() {
CtMethod<?> method = this.getFactory().createMethod();
method.setSimpleName(getSimpleName());
method.setType(getType().clone());
method.setType(getType() != null ? getType().clone() : null);
method.setExtendedModifiers(Collections.singleton(new CtExtendedModifier(ModifierKind.PUBLIC, true)));
method.setImplicit(true);

Expand All @@ -61,7 +61,7 @@ private CtFieldReference<?> getRecordFieldReference() {
CtFieldReference<?> reference = getFactory().createFieldReference()
.setFinal(true)
.setStatic(false)
.setType(getType())
.setType(getType() != null ? getType().clone() : null)
.setSimpleName(getSimpleName());

// We have a parent record, make the field refer to it. Ideally we could do this all the time, but if we
Expand All @@ -77,7 +77,7 @@ private CtFieldReference<?> getRecordFieldReference() {
public CtField<?> toField() {
CtField<?> field = this.getFactory().createField();
field.setSimpleName(getSimpleName());
field.setType(getType());
field.setType(getType() != null ? getType().clone() : null);
Set<CtExtendedModifier> modifiers = new HashSet<>();
modifiers.add(new CtExtendedModifier(ModifierKind.PRIVATE, true));
modifiers.add(new CtExtendedModifier(ModifierKind.FINAL, true));
Expand Down

0 comments on commit 99da5e2

Please sign in to comment.