Groovy Parser Failes on Method Reference Operator ::
I am using
- OpenRewrite Latest
How are you running OpenRewrite?
Gradle
What is the smallest, simplest way to reproduce the problem?
test.gradle
final String[] finalDeps =
List.of(new Object()).stream().toArray(String[]::new);
What is the full stack trace of any errors you encountered?
org.openrewrite.groovy.GroovyParsingException: Failed to parse buildSrc/src/main/groovy/test.gradle at cursor position 93. The next 10 characters in the original source are `;
`
at org.openrewrite.groovy.GroovyParserVisitor.visit(GroovyParserVisitor.java:174)
at org.openrewrite.groovy.GroovyParser.lambda$parseInputs$4(GroovyParser.java:154)
at [email protected]/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.
Are you interested in [contributing a fix to OpenRewrite](
Yes
Hi @blipper!
This one is going to be a little difficult to achieve, but it's possible if we perform a similar thing to what has been done for the major Java versions so far.
Presently, the rewrite-groovy project is built against Groovy 3.0 which is backwards compatible at the AST level with Groovy 2.x. However, to handle the Java 8 syntax requires the Groovy 4.0 "Parrot" parser. Since the migration of the packages was wrapped up in the 4.0 release as the project moved under the Apache Foundation this means the the AST itself wasn't backwards compatible and would have to be built back up using the new types and compiler.
Interesting. I looked at the Groovy 4 release notes, which mention quite a few new language features, but nothing about method references. Qas that maybe already part of Groovy 3?
@knutwannheden, hmm... thats interesting, but you are right. I could have sworn that it was a Groovy 4 thing for method references, but it is actually available in Groovy 3. So that shouldn't be too bad to add in then.