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

Static compilation confused by factory methods, map initializers and generics

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.3.0-rc-1
    • Static compilation
    • None

    Description

      @groovy.transform.CompileStatic
      class TestFails<T extends Comparable> {
          List<T> x
          static <M extends Comparable> TestFails<M> select(List<M> x) { 
              new TestFails<M>(x: x) 
          }
      }
      

      Error:(9, 22) Groovyc: [Static type checking] - Cannot assign value of type java.util.List <M> to variable of type java.util.List <T>

      @groovy.transform.CompileStatic
      class TestWorks<T extends Comparable> {
          List<T> x
          static <M extends Comparable> TestWorks<M> select(List<M> x) {
              new TestWorks<M>()
          }
      }
      

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            ddimitrov Dimitar Dimitrov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: