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

STC: multiple instanceof checks produce different results

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      Consider the following:

      @groovy.transform.TypeChecked test1(CharSequence chars) {
        if (chars instanceof Cloneable && chars instanceof Closeable) {
            chars
        }
      }
      @groovy.transform.TypeChecked test2(CharSequence chars) {
        if (chars instanceof Cloneable) {
          if (chars instanceof Closeable) {
            chars
          }
        }
      }
      

      The last occurrence of "chars" in test1 has the inferred type "CharSequence & Cloneable & Closeable". However the last occurrence of "chars" in test2 has the inferred type "CharSequence & Closeable" instead of the expected result like test1.

      Attachments

        Issue Links

        Activity

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

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment