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

Returning "null" in a function reports an invalid type checking error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0-rc-2
    • 2.0-rc-3
    • Static Type Checker
    • None

    Description

      The following code is valid, but it reports some compilation errors:

      @groovy.transform.CompileStatic
      class Test {
       
        List getList() {
          null
        }
        
      }
      

      1 compilation error:

      [Static type checking] - Cannot return value of type java.lang.Object on method returning type java.util.List -> java.util.List <E extends java.lang.Object -> java.lang.Object>
      at line: 5, column: 5

      Attachments

        Activity

          People

            melix C├ędric Champeau
            ariel.andres.morelli Ariel Morelli Andres
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: