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

failure in static compilation with getAt

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.5
    • Static Type Checker
    • None

    Description

      class l {
        static <T> T getAt(T x) {return x}
      }
      
      @groovy.transform.CompileStatic
      def m() {
        List<Integer> x =  l[1,2,3]
        return x
      }
      
      m()
      

      this code fails to compile

      {pre}
      [Static type checking] - Cannot find matching method java.lang.Class#getAt(java.util.List). Please check if the declared type is correct and if the method exists.
      @ line 7, column 22.
      List<Integer> x = l[1,2,3]
      ^

      1 error{pre}

      The error message makes me think that l is seen as an instance of Class instead of the class l. Changing the class name l does not make a difference for me. I tested with groovy 3.0.1 and 2.4.7, same error, so unlikely to be new

      Attachments

        Activity

          People

            emilles Eric Milles
            blackdrag Jochen Theodorou
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: