Skip to content

Commit 6f299dc

Browse files
Groovy: fix parsing of method calls on int literals (#7493)
1 parent 0d7bb7d commit 6f299dc

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

rewrite-groovy/src/main/java/org/openrewrite/groovy/GroovyParserVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1668,7 +1668,7 @@ public void visitConstantExpression(ConstantExpression expression) {
16681668
}
16691669
for (; i < source.length(); i++) {
16701670
char c = source.charAt(i);
1671-
if (!(isJavaIdentifierPart(c) || (c == '.' && source.length() > (i + 1) && isJavaIdentifierPart(source.charAt(i + 1))))) {
1671+
if (!(isJavaIdentifierPart(c) || (c == '.' && source.length() > (i + 1) && Character.isDigit(source.charAt(i + 1))))) {
16721672
break;
16731673
}
16741674
}

rewrite-groovy/src/test/java/org/openrewrite/groovy/tree/MethodInvocationTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ void emptyArgsWithParens() {
6767
);
6868
}
6969

70+
@Test
71+
void closureArgumentOnNumericLiteralReceiver() {
72+
rewriteRun(
73+
groovy("50.times { 1 }")
74+
);
75+
}
76+
7077
@Test
7178
void noParentheses() {
7279
rewriteRun(

0 commit comments

Comments
 (0)