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

NullPointerException in phase 'instruction selection' when using spread-dot operator on an array in static compilation mode

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.6
    • 2.3.7
    • Static compilation
    • None

    Description

      When using spread-dot operator on an array in @CompileStatic annotated method the following error is raised:

      BUG! exception in phase 'instruction selection' in source unit 'ConsoleScript9' unexpected NullpointerException
      Caused by: java.lang.NullPointerException

      Reproducible example:

      import groovy.transform.CompileStatic
      
      @CompileStatic
      def foo() {
          new File("/").listFiles()*.name
      }
      
      foo()
      

      The problem doesn't occur when the operator is used on a list:

      import groovy.transform.CompileStatic
      
      @CompileStatic
      def foo() {
          new File("/").listFiles().toList()*.name
      }
      
      foo()
      

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: