Skip to content

Commit

Permalink
[fixes #2917] Use $value instead of value in lazy getter
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawi01 authored and rspilker committed Mar 18, 2024
1 parent 23307eb commit c93400d
Show file tree
Hide file tree
Showing 23 changed files with 361 additions and 361 deletions.
4 changes: 2 additions & 2 deletions src/core/lombok/eclipse/handlers/HandleGetter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2022 The Project Lombok Authors.
* Copyright (C) 2009-2024 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
Expand Down Expand Up @@ -323,7 +323,7 @@ public Statement[] createSimpleGetterBody(ASTNode source, EclipseNode fieldNode)
TYPE_MAP = Collections.unmodifiableMap(m);
}

private static char[] valueName = "value".toCharArray();
private static char[] valueName = "$value".toCharArray();
private static char[] actualValueName = "actualValue".toCharArray();

private static final int PARENTHESIZED = (1 << ASTNode.ParenthesizedSHIFT) & ASTNode.ParenthesizedMASK;
Expand Down
4 changes: 2 additions & 2 deletions src/core/lombok/javac/handlers/HandleGetter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2022 The Project Lombok Authors.
* Copyright (C) 2009-2024 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
Expand Down Expand Up @@ -358,7 +358,7 @@ public List<JCStatement> createLazyGetterBody(JavacTreeMaker maker, JavacNode fi
}
if (copyOfBoxedFieldType == null) copyOfBoxedFieldType = copyType(maker, field, source);

Name valueName = fieldNode.toName("value");
Name valueName = fieldNode.toName("$value");
Name actualValueName = fieldNode.toName("actualValue");

/* java.lang.Object value = this.fieldName.get();*/ {
Expand Down
14 changes: 7 additions & 7 deletions test/transform/resource/after-delombok/DelegateOnGetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ private interface Bar {
}
@java.lang.SuppressWarnings({"all", "unchecked"})
public Bar getBar() {
java.lang.Object value = this.bar.get();
if (value == null) {
java.lang.Object $value = this.bar.get();
if ($value == null) {
synchronized (this.bar) {
value = this.bar.get();
if (value == null) {
$value = this.bar.get();
if ($value == null) {
final Bar actualValue = new Bar() {
public void setList(java.util.ArrayList<String> list) {
}
public int getInt() {
return 42;
}
};
value = actualValue == null ? this.bar : actualValue;
this.bar.set(value);
$value = actualValue == null ? this.bar : actualValue;
this.bar.set($value);
}
}
}
return (Bar) (value == this.bar ? null : value);
return (Bar) ($value == this.bar ? null : $value);
}
@java.lang.SuppressWarnings("all")
public void setList(final java.util.ArrayList<java.lang.String> list) {
Expand Down
14 changes: 7 additions & 7 deletions test/transform/resource/after-delombok/GetterLazy.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ static class ValueType {
private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> fieldName = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>();
@java.lang.SuppressWarnings({"all", "unchecked"})
public ValueType getFieldName() {
java.lang.Object value = this.fieldName.get();
if (value == null) {
java.lang.Object $value = this.fieldName.get();
if ($value == null) {
synchronized (this.fieldName) {
value = this.fieldName.get();
if (value == null) {
$value = this.fieldName.get();
if ($value == null) {
final ValueType actualValue = new ValueType();
value = actualValue == null ? this.fieldName : actualValue;
this.fieldName.set(value);
$value = actualValue == null ? this.fieldName : actualValue;
this.fieldName.set($value);
}
}
}
return (ValueType) (value == this.fieldName ? null : value);
return (ValueType) ($value == this.fieldName ? null : $value);
}
}
84 changes: 42 additions & 42 deletions test/transform/resource/after-delombok/GetterLazyArguments.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,99 +21,99 @@ static String stringRunnable(String arg1, Runnable arg2) {

@java.lang.SuppressWarnings({"all", "unchecked"})
public String getField1() {
java.lang.Object value = this.field1.get();
if (value == null) {
java.lang.Object $value = this.field1.get();
if ($value == null) {
synchronized (this.field1) {
value = this.field1.get();
if (value == null) {
$value = this.field1.get();
if ($value == null) {
final String actualValue = stringInt(("a"), (1));
value = actualValue == null ? this.field1 : actualValue;
this.field1.set(value);
$value = actualValue == null ? this.field1 : actualValue;
this.field1.set($value);
}
}
}
return (String) (value == this.field1 ? null : value);
return (String) ($value == this.field1 ? null : $value);
}

@java.lang.SuppressWarnings({"all", "unchecked"})
public String getField2() {
java.lang.Object value = this.field2.get();
if (value == null) {
java.lang.Object $value = this.field2.get();
if ($value == null) {
synchronized (this.field2) {
value = this.field2.get();
if (value == null) {
$value = this.field2.get();
if ($value == null) {
final String actualValue = stringInt(true ? "a" : "b", true ? 1 : 0);
value = actualValue == null ? this.field2 : actualValue;
this.field2.set(value);
$value = actualValue == null ? this.field2 : actualValue;
this.field2.set($value);
}
}
}
return (String) (value == this.field2 ? null : value);
return (String) ($value == this.field2 ? null : $value);
}

@java.lang.SuppressWarnings({"all", "unchecked"})
public String getField3() {
java.lang.Object value = this.field3.get();
if (value == null) {
java.lang.Object $value = this.field3.get();
if ($value == null) {
synchronized (this.field3) {
value = this.field3.get();
if (value == null) {
$value = this.field3.get();
if ($value == null) {
final String actualValue = stringInt(("a"), true ? 1 : 0);
value = actualValue == null ? this.field3 : actualValue;
this.field3.set(value);
$value = actualValue == null ? this.field3 : actualValue;
this.field3.set($value);
}
}
}
return (String) (value == this.field3 ? null : value);
return (String) ($value == this.field3 ? null : $value);
}

@java.lang.SuppressWarnings({"all", "unchecked"})
public String getField4() {
java.lang.Object value = this.field4.get();
if (value == null) {
java.lang.Object $value = this.field4.get();
if ($value == null) {
synchronized (this.field4) {
value = this.field4.get();
if (value == null) {
$value = this.field4.get();
if ($value == null) {
final String actualValue = stringRunnable(fun(), () -> {
});
value = actualValue == null ? this.field4 : actualValue;
this.field4.set(value);
$value = actualValue == null ? this.field4 : actualValue;
this.field4.set($value);
}
}
}
return (String) (value == this.field4 ? null : value);
return (String) ($value == this.field4 ? null : $value);
}

@java.lang.SuppressWarnings({"all", "unchecked"})
public String getField5() {
java.lang.Object value = this.field5.get();
if (value == null) {
java.lang.Object $value = this.field5.get();
if ($value == null) {
synchronized (this.field5) {
value = this.field5.get();
if (value == null) {
$value = this.field5.get();
if ($value == null) {
final String actualValue = stringRunnable(("a"), () -> {
});
value = actualValue == null ? this.field5 : actualValue;
this.field5.set(value);
$value = actualValue == null ? this.field5 : actualValue;
this.field5.set($value);
}
}
}
return (String) (value == this.field5 ? null : value);
return (String) ($value == this.field5 ? null : $value);
}

@java.lang.SuppressWarnings({"all", "unchecked"})
public String getField6() {
java.lang.Object value = this.field6.get();
if (value == null) {
java.lang.Object $value = this.field6.get();
if ($value == null) {
synchronized (this.field6) {
value = this.field6.get();
if (value == null) {
$value = this.field6.get();
if ($value == null) {
final String actualValue = true ? stringInt(true ? "a" : "b", true ? 1 : 0) : "";
value = actualValue == null ? this.field6 : actualValue;
this.field6.set(value);
$value = actualValue == null ? this.field6 : actualValue;
this.field6.set($value);
}
}
}
return (String) (value == this.field6 ? null : value);
return (String) ($value == this.field6 ? null : $value);
}
}
28 changes: 14 additions & 14 deletions test/transform/resource/after-delombok/GetterLazyBoolean.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,32 @@ public java.lang.String toString() {
}
@java.lang.SuppressWarnings({"all", "unchecked"})
public boolean isBooleanValue() {
java.lang.Object value = this.booleanValue.get();
if (value == null) {
java.lang.Object $value = this.booleanValue.get();
if ($value == null) {
synchronized (this.booleanValue) {
value = this.booleanValue.get();
if (value == null) {
$value = this.booleanValue.get();
if ($value == null) {
final boolean actualValue = calculateBoolean();
value = actualValue;
this.booleanValue.set(value);
$value = actualValue;
this.booleanValue.set($value);
}
}
}
return (java.lang.Boolean) value;
return (java.lang.Boolean) $value;
}
@java.lang.SuppressWarnings({"all", "unchecked"})
public boolean isOtherBooleanValue() {
java.lang.Object value = this.otherBooleanValue.get();
if (value == null) {
java.lang.Object $value = this.otherBooleanValue.get();
if ($value == null) {
synchronized (this.otherBooleanValue) {
value = this.otherBooleanValue.get();
if (value == null) {
$value = this.otherBooleanValue.get();
if ($value == null) {
final boolean actualValue = !calculateBoolean();
value = actualValue;
this.otherBooleanValue.set(value);
$value = actualValue;
this.otherBooleanValue.set($value);
}
}
}
return (java.lang.Boolean) value;
return (java.lang.Boolean) $value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ public java.lang.String toString() {

@java.lang.SuppressWarnings({"all", "unchecked"})
public String getValue() {
java.lang.Object value = this.value.get();
if (value == null) {
java.lang.Object $value = this.value.get();
if ($value == null) {
synchronized (this.value) {
value = this.value.get();
if (value == null) {
$value = this.value.get();
if ($value == null) {
final String actualValue = "";
value = actualValue == null ? this.value : actualValue;
this.value.set(value);
$value = actualValue == null ? this.value : actualValue;
this.value.set($value);
}
}
}
return (String) (value == this.value ? null : value);
return (String) ($value == this.value ? null : $value);
}

@java.lang.SuppressWarnings("all")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ class GetterLazyErrorPosition {

@java.lang.SuppressWarnings({"all", "unchecked"})
public String getField() {
java.lang.Object value = this.field.get();
if (value == null) {
java.lang.Object $value = this.field.get();
if ($value == null) {
synchronized (this.field) {
value = this.field.get();
if (value == null) {
$value = this.field.get();
if ($value == null) {
final String actualValue = true ? "" : new ErrorPosition();
value = actualValue == null ? this.field : actualValue;
this.field.set(value);
$value = actualValue == null ? this.field : actualValue;
this.field.set($value);
}
}
}
return (String) (value == this.field ? null : value);
return (String) ($value == this.field ? null : $value);
}
}
28 changes: 14 additions & 14 deletions test/transform/resource/after-delombok/GetterLazyGenerics.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@ public static <E> E getAny() {
}
@java.lang.SuppressWarnings({"all", "unchecked"})
public E getField() {
java.lang.Object value = this.field.get();
if (value == null) {
java.lang.Object $value = this.field.get();
if ($value == null) {
synchronized (this.field) {
value = this.field.get();
if (value == null) {
$value = this.field.get();
if ($value == null) {
final E actualValue = getAny();
value = actualValue == null ? this.field : actualValue;
this.field.set(value);
$value = actualValue == null ? this.field : actualValue;
this.field.set($value);
}
}
}
return (E) (value == this.field ? null : value);
return (E) ($value == this.field ? null : $value);
}
@java.lang.SuppressWarnings({"all", "unchecked"})
public long getField2() {
java.lang.Object value = this.field2.get();
if (value == null) {
java.lang.Object $value = this.field2.get();
if ($value == null) {
synchronized (this.field2) {
value = this.field2.get();
if (value == null) {
$value = this.field2.get();
if ($value == null) {
final long actualValue = System.currentTimeMillis();
value = actualValue;
this.field2.set(value);
$value = actualValue;
this.field2.set($value);
}
}
}
return (java.lang.Long) value;
return (java.lang.Long) $value;
}
}
Loading

0 comments on commit c93400d

Please sign in to comment.