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

Static Type Checker: Ternary operator doesn't allow nulls

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0-rc-3
    • 2.0-rc-4
    • None
    • None

    Description

      Following code:

      import groovy.transform.CompileStatic
      @CompileStatic
      File findFile() {
          String str = ""
          File f = str ? new File(str) : null
      }
      

      Produces:

      [Static type checking] - Cannot assign value of type java.lang.Object to variable of type java.io.File
       at line: 8, column: 5
      

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: