You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2026/05/07 18:38:00 UTC

[jira] [Updated] (GROOVY-12000) STC: instanceof or combined with not

     [ https://issues.apache.org/jira/browse/GROOVY-12000?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles updated GROOVY-12000:
---------------------------------
    Description: 
Consider the following:
{code:groovy}
@groovy.transform.TypeChecked
void test(Number number) {
  if (!(number instanceof Cloneable || number instanceof Closeable)) {
    number
  } else {
    number
  }
}
{code}
Currently this passes the check for "can invert" and produces a type like (Number & (Cloneable | Closeable))" for the else path. Not sure if we're ready for that or not.

  was:
Consider the following:
{code:groovy}
@groovy.transform.TypeChecked
void test(Number number) {
  if (!(number instanceof Cloneable || number instanceof Closeable)) {
    number
  } else {
    number
  }
}
{code}

Currently this passes the check for "can invert" and produces a type like (Number & (Cloneable | Closeable))".  Not sure if we're ready for that or not.


> STC: instanceof or combined with not
> ------------------------------------
>
>                 Key: GROOVY-12000
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12000
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Eric Milles
>            Priority: Major
>
> Consider the following:
> {code:groovy}
> @groovy.transform.TypeChecked
> void test(Number number) {
>   if (!(number instanceof Cloneable || number instanceof Closeable)) {
>     number
>   } else {
>     number
>   }
> }
> {code}
> Currently this passes the check for "can invert" and produces a type like (Number & (Cloneable | Closeable))" for the else path. Not sure if we're ready for that or not.



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