Skip to content

Commit

Permalink
Minor revision to ArrayType#create to account for types on J.ArrayTyp…
Browse files Browse the repository at this point in the history
…e from old Groovy LSTs. (#3865)
  • Loading branch information
traceyyoshima authored Dec 29, 2023
1 parent b537267 commit cd3cdcf
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rewrite-java/src/main/java/org/openrewrite/java/tree/J.java
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,14 @@ static ArrayType create(
@Nullable JLeftPadded<Space> dimension,
@Nullable JavaType type) {
if (dimensions != null) {
// To create a consistent JavaType$Array from old Groovy and Java LSTs, we need to map the element type.
// The JavaType from GroovyTypeMapping was a JavaType$Array, while the JavaType from JavaTypeMapping was a JavaType$Class.
JavaType updated = elementType.getType();
while (updated instanceof JavaType.Array) {
updated = ((JavaType.Array) updated).getElemType();
}
elementType = elementType.withType(updated);

if (dimensions.isEmpty()) {
// varargs in Javadoc
type = new JavaType.Array(null, elementType.getType());
Expand Down

0 comments on commit cd3cdcf

Please sign in to comment.