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

Type inference fails in @CompileStatic for collection iteration closure argument

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.2.1
    • None
    • Static compilation
    • None

    Description

      @CompileStatic
      class CompileStaticTest
      {
        void requiresString(String s)
        {
          println(s)
        }
        void showsError()
        {
          List<String> ls = ["a", "b"]
          ls.each {requiresString(it)}
        }
      }
      

      Yields compiler error:

      Groovyc: [Static type checking] - Cannot find matching method com.<pathdeleted>.CompileStaticTest#requiresString(java.lang.Object). Please check if the declared type is right and if the method exists.

      Attachments

        Issue Links

          Activity

            People

              melix Cédric Champeau
              sean.true Sean True
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: