Skip to content

Groovy parsing failure for @Canonical annotation on a class definition #6302

@greg-at-moderne

Description

@greg-at-moderne

What version of OpenRewrite are you using?

Current main = e1f2efd

What is the smallest, simplest way to reproduce the problem?

    @Test
    void canonical() {
        rewriteRun(
          groovy(
            """
              import groovy.transform.Canonical
              
              @Canonical
              class Person {
                  String name
                  int age
              }
              """
          )
        );
    }

added to rewrite-groovy/src/test/java/org/openrewrite/groovy/tree/AnnotationTest.java

fails with:

Caused by: java.lang.IllegalStateException: Unexpected class type: 
	at org.openrewrite.groovy.GroovyParserVisitor$RewriteGroovyClassVisitor.visitClass(GroovyParserVisitor.java:257)
	at org.openrewrite.groovy.GroovyParserVisitor.convertTopLevelStatement(GroovyParserVisitor.java:2418)
	at org.openrewrite.groovy.GroovyParserVisitor.visit(GroovyParserVisitor.java:195)
	... 16 more

OSS repro

https://github.com/nebula-plugins/gradle-dependency-lock-plugin/blob/ead476a6e29422d5ce4b8dfadcf66d4692a74e76/src/main/groovy/nebula/plugin/dependencylock/DependencyLockWriter.groovy#L10

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggroovy

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions