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

Trait with generic will fail compilation if it has a static method that return the defined generic type.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Not A Problem
    • 2.5.0, 2.5.1, 2.5.2, 2.5.3
    • None
    • Compiler
    • None
    • macOS 10.14
      OpenJDK 1.8.0_181-b02

    Description

      If you define a trait with generic type T and have a static method that return that type, compilation will fail with the following message:

      Error:(5, 5) Groovyc: unable to resolve class T

      Simple code for reproducing this bug:

      trait MyTrait<T extends List> {
          static T myMethod() {
              return [1, 2, 3]
          }
      }

       Groovy 2.4.x does not have this issue, from my testing this only happen in 2.5.x

      Attachments

        Activity

          People

            Unassigned Unassigned
            Elfianto Dwi Elfianto
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: