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

Fail to infer auto-return type from ternary operator

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    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

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment