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

Fail to infer auto-return type from ternary operator

    XMLWordPrintableJSON

Details

    Description

      @groovy.transform.Field
      String x = "X"
      
      @groovy.transform.CompileStatic
      public List<String> getStrings() {
      	x ? [x] : Collections.emptyList() // fail
              // return x ? [x] : Collections.emptyList() // succeed with `return`
      }
      
      getStrings()
      

      SEE GROOVY-7753

      Attachments

        Issue Links

          Activity

            People

              jwagenleitner John Wagenleitner
              daniel_sun Daniel Sun
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: