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

Cannot extend trait with generic parameter

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.0-beta-1
    • Fix Version/s: 2.3.0-beta-2
    • Component/s: None
    • Labels:
      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

            • Assignee:
              melix C├ędric Champeau
              Reporter:
              mperry Mark Perry
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: