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

STC: multiple instanceof checks produce different results

    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

            People

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

              Dates

                Created:
                Updated:
                Resolved: