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

Groovy type extension does not type check for generic parameter

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.9, 2.2.1
    • 2.2.2
    • Static Type Checker
    • None
    • Windows, Java 1.7.0_45, Gradle 1.10

    Description

      The repository at https://github.com/mperry/bug-extension-module-generics demonstrates a simple type checking issue for Groovy extension modules

      The method "to" is defined as a static method in the classes Normal and ListExtension where ListExtension is a Groovy extension module and Normal a regular class.

      static <A, B> List<B> to(List<A> list, B b) {
          list.collect { A a -> b }
      }
      

      Both are type checked. The test class attempts to call both methods, but the "to" method in the extension class will not type check with the generic parameter. The program works when type checking is removed.

      Using:

      • Groovy 2.1.9
      • Gradle 1.10
      • Java 1.7.0_45

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: