Open
Description
What version of OpenRewrite are you using?
Current main = fc68c8d
What is the smallest, simplest way to reproduce the problem?
The following test fails:
@Test
void defParen() {
rewriteRun(
groovy(
"""
def (key, value) = "a1:b2".split(":")
println(key)
println(value)
"""
)
);
}
with:
Caused by: java.lang.ClassCastException: class org.codehaus.groovy.ast.expr.ArgumentListExpression cannot be cast to class org.codehaus.groovy.ast.expr.VariableExpression (org.codehaus.groovy.ast.expr.ArgumentListExpression and org.codehaus.groovy.ast.expr.VariableExpression are in unnamed module of loader 'app')
at org.codehaus.groovy.ast.expr.DeclarationExpression.getVariableExpression(DeclarationExpression.java:103)
at org.openrewrite.groovy.GroovyParserVisitor$RewriteGroovyVisitor.visitDeclarationExpression(GroovyParserVisitor.java:1363)
at org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:89)
at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:120)
which I think is a valid Groovy program.
Context
I found the same pattern in an open-source: https://github.com/liquibase/liquibase-gradle-plugin/blob/966efedabb949b5eae661a1e0fed4461ece187ed/src/main/groovy/org/liquibase/gradle/ArgumentBuilder.groovy#L269
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Backlog