Skip to content

Commit

Permalink
Fix index out of bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurens-W committed Jan 21, 2025
1 parent d49141c commit f36a1d9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion rewrite-java/src/main/java/org/openrewrite/java/tree/J.java
Original file line number Diff line number Diff line change
Expand Up @@ -5122,7 +5122,14 @@ final class SwitchExpression implements J, Expression, TypedTree {
public J visitBlock(Block block, AtomicReference<JavaType> javaType) {
if (!block.getStatements().isEmpty()) {
Case caze = (Case) block.getStatements().get(0);
javaType.set(caze.getExpressions().get(0).getType());
for (J j : caze.getCaseLabels()) {
if (j instanceof TypedTree) {
if (((TypedTree) j).getType() != null) {
javaType.set(((TypedTree) j).getType());
break;
}
}
}
}
return block;
}
Expand Down

0 comments on commit f36a1d9

Please sign in to comment.