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

Optimized foreach loops should perform a null check

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 2.4.2
    • 2.4.3
    • Static compilation
    • None

    Description

      The following code is a regression, because previously the code used an iterator, which in case of null returned an empty iterator. With the optimized path, the loop will fail.

      @CompileStatic
      private void foo(String[] arr) {
         for (String s in arr) {
            println(s)
         }
      }
      
      foo(null)
      

      Attachments

        Activity

          People

            melix Cédric Champeau
            melix Cédric Champeau
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: