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

Cannot extend trait with generic parameter

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.0-beta-1
    • 2.3.0-beta-2
    • None
    • None

    Description

      I get a compiler error when I try to extend a trait with a generic type parameter.

      trait Functor<T> { }
      trait Applicative<App> extends Functor<App> { }
      

      does not compile with the error message:

      src\main\groovy\com\github\mperry\Applicative.groovy: 14: A transform used a generics containing ClassNode com.github.mperry.Functor <T> for the super class com.github.mperry.Applicative directly. You are not supposed to do this. Please create a new ClassNode referring to the old ClassNode and use the new ClassNode instead of the old one. Otherwise the compiler will create wrong descriptors and a potential NullPointerException in TypeResolver in the OpenJDK. If this is not your own doing, please report this bug to the writer
       of the transform. @ line 14, column 1.
         trait Applicative extends Functor {
      :compileGroovy FAILED
         ^
      

      Changing the Applicative trait to a simpler form gets the same compiler error:

      trait Functor<T> { }
      trait Applicative extends Functor { }
      

      Extending from a non-generic trait compiles:

      trait Functor { }
      trait Applicative<App> extends Functor { }
      

      I am using Gradle 1.11, Java 7 and Windows 7.

      Attachments

        Activity

          People

            melix Cédric Champeau
            mperry Mark Perry
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: