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

Groovy type extension does not type check for generic parameter

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.9, 2.2.1
    • Fix Version/s: 2.2.2
    • Component/s: Static Type Checker
    • Labels:
      None
    • Environment:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: