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

regression in varargs treatment for static compilation

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.3.0-rc-4
    • Component/s: None
    • Labels:
      None

      Description

      The following example works fine in 2.2.2:

      import groovy.transform.CompileStatic
      
      @CompileStatic
      def extractInfo(String s) {
        def squareNums = s.findAll(/\d+/) { String num -> num.toInteger() }.collect{ Integer num -> num ** 2 }
        def wordSizePlusNum = s.findAll(/\s*(\w+)\s*(\d+)/) { _, String word, String num -> word.size() + num.toInteger() }
        [squareNums, wordSizePlusNum]
      }
      
      assert extractInfo(" ab 12 cdef 34 jhg ") == [[144, 1156], [14, 38]]
      

      but in 2.3.0-rc-2 it gives the following errors:

      4 compilation errors:
      
      Expected parameter of type java.lang.String[] but got java.lang.String
       at line: 5, column: 39
      
      [Static type checking] - Cannot find matching method [Ljava.lang.String;#toInteger(). Please check if the declared type is right and if the method exists.
       at line: 5, column: 53
      
      Expected parameter of type java.lang.Object but got java.lang.Integer
       at line: 5, column: 80
      
      [Static type checking] - Cannot find matching method java.lang.Object#power(int). Please check if the declared type is right and if the method exists.
       at line: 5, column: 95
      

        Attachments

          Activity

            People

            • Assignee:
              melix C├ędric Champeau
              Reporter:
              paulk Paul King
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: