Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10995

Classes are compiled in Groovy 3 and Java but fails in Groovy 4

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.10
    • None
    • Compiler
    • None

    Description

      We use Groovy 3. And I tried to migrate the existing application to use Groovy 4. 

      I have a compilation issue in the code and the same behavior in IntelliJ IDEA, because it uses Groovy 4 syntax by default.

      What I have:

      // A simple interface with generic parameter
      // This is Java class compiled by Java
      interface MyInterface<T> {
      } 
      // A simple annotation that expects an MyInterface implemenations
      // This is Java class compiled by Java
      @Retention(RetentionPolicy.RUNTIME)
      @Target(ElementType.METHOD)
      @interface MyAnnotation {
          Class<? extends MyInterface<?>> value()
      } 
      //A class that implements MyInterface and ignores type raw type using warnings
      //This is Groovy class located at the same package with the next code
      public class MyClass implements MyInterface { 
      }
      
      // A method that uses MyAnnotation with MyClass parameter
      //This is Groovy code that fails and located at the same package with MyClass
      @MyAnnotation(value = com.example.MyClass)
      static void main(String[] args) { 
      }

      This code compiles in Groovy 3 and compiles in Java but fails to compile in Groovy 4.0.10

      The code starts to compile in Groovy 4 If I change MyClass implementation to:

      public class MyClass implements MyInterface<Object> {
      } 

      I think it is a bug, please, validate and fix it.

      Attachments

        Activity

          People

            Unassigned Unassigned
            mkamalov Marat Kamalov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: