Eric Milles created GROOVY-11290:
------------------------------------

             Summary: STC: multiple instanceof checks produce different results
                 Key: GROOVY-11290
                 URL: https://issues.apache.org/jira/browse/GROOVY-11290
             Project: Groovy
          Issue Type: Bug
          Components: Static Type Checker
    Affects Versions: 4.0.18
            Reporter: Eric Milles


Consider the following:
{code:groovy}
@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
    }
  }
}
{code}

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}}.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to