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

failure in static compilation with getAt

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Static Type Checker
    • Labels:
      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

            • Assignee:
              Unassigned
              Reporter:
              blackdrag Jochen Theodorou
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: