Skip to content

Commit

Permalink
[fixes #3274] Reset erasure_field of symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawi01 committed Jan 9, 2023
1 parent 731bb18 commit 5f0582b
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/core/lombok/javac/handlers/HandleUtilityClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,11 @@ private void changeModifiersAndGenerateConstructor(JavacNode typeNode, JavacNode
JCClassDecl innerClassDecl = (JCClassDecl) element.get();
innerClassDecl.mods.flags |= Flags.STATIC;
ClassSymbol innerClassSymbol = innerClassDecl.sym;
if (innerClassSymbol != null && innerClassSymbol.type instanceof ClassType) {
((ClassType) innerClassSymbol.type).setEnclosingType(Type.noType);
if (innerClassSymbol != null) {
if (innerClassSymbol.type instanceof ClassType) {
((ClassType) innerClassSymbol.type).setEnclosingType(Type.noType);
}
innerClassSymbol.erasure_field = null;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/stubs/com/sun/tools/javac/code/Symbol.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public abstract class Symbol implements Element {
public Type type;
public Name name;
public Symbol owner;
public Type erasure_field;

public long flags() { return 0; }
public boolean isStatic() { return false; }
Expand Down
21 changes: 21 additions & 0 deletions test/transform/resource/after-delombok/UtilityClassGeneric.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
final class UtilityClassGeneric {
static <T> T convertValue(Class<T> toValueType) {
return null;
}

static DTO convert(Object json) {
return convertValue(DTO.class);
}

static Object convert(DTO dto) {
return null;
}

static class DTO {
}

@java.lang.SuppressWarnings("all")
private UtilityClassGeneric() {
throw new java.lang.UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
}
21 changes: 21 additions & 0 deletions test/transform/resource/after-ecj/UtilityClassGeneric.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import lombok.experimental.UtilityClass;
final @UtilityClass class UtilityClassGeneric {
static class DTO {
DTO() {
super();
}
}
static <T>T convertValue(Class<T> toValueType) {
return null;
}
static DTO convert(Object json) {
return convertValue(DTO.class);
}
static Object convert(DTO dto) {
return null;
}
private @java.lang.SuppressWarnings("all") UtilityClassGeneric() {
super();
throw new java.lang.UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
}
18 changes: 18 additions & 0 deletions test/transform/resource/before/UtilityClassGeneric.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import lombok.experimental.UtilityClass;
@UtilityClass
class UtilityClassGeneric {
<T> T convertValue(Class<T> toValueType) {
return null;
}

DTO convert(Object json) {
return convertValue(DTO.class);
}

Object convert(DTO dto) {
return null;
}

class DTO {
}
}

0 comments on commit 5f0582b

Please sign in to comment.