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

Static compilation confused by factory methods, map initializers and generics

    XMLWordPrintableJSON

    Details

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

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

              Dates

              • Created:
                Updated:
                Resolved: