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

VerifyError with CompileStatic

    XMLWordPrintableJSON

    Details

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

      Description

      The following code causes a VerifyError:

      import groovy.transform.CompileStatic
      
      @CompileStatic
      def extractSquares(String s) {
        s.findAll(~/\d+/) { String num -> num.toInteger() }.collect{ it ** 2 }
      }
      
      assert extractSquares(" ab 12 cdef 34 jhg ") == [144, 1156]
      

      This occurs when the DGM method has the closure param not annotated with @CP or annotated with the following value:

      @ClosureParams(value=FromString.class, options={"java.lang.String","java.lang.String[]"}
      

      Adding a type to the last closure makes the error vanish:

      collect{ Integer num -> num ** 2 }
      

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: