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 2023/04/10 20:41:00 UTC

[jira] [Updated] (GROOVY-11007) STC: instanceof guard for property loses type information

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

Eric Milles updated GROOVY-11007:
---------------------------------
    Description: 
Consider the following:
{code:groovy}
interface I {
    CharSequence getCharSequence()
}

void accept(CharSequence cs) { }

void test(I i) {
    i.with {
        if (charSequence instanceof String) {
            charSequence.toUpperCase()
            accept(charSequence)
        }
    }
}

test({ -> 'works' } as I)
{code}


Reports "Cannot find matching method script#accept(java.lang.Object)".

  was:
Consider the following:
{code:groovy|
interface I {
    CharSequence getCharSequence()
}

void accept(CharSequence cs) { }

void test(I i) {
    i.with {
        if (charSequence instanceof String) {
            charSequence.toUpperCase()
            accept(charSequence)
        }
    }
}

test({ -> 'works' } as I)
{code}


Reports "Cannot find matching method script#accept(java.lang.Object)".


> STC: instanceof guard for property loses type information
> ---------------------------------------------------------
>
>                 Key: GROOVY-11007
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11007
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>
> Consider the following:
> {code:groovy}
> interface I {
>     CharSequence getCharSequence()
> }
> void accept(CharSequence cs) { }
> void test(I i) {
>     i.with {
>         if (charSequence instanceof String) {
>             charSequence.toUpperCase()
>             accept(charSequence)
>         }
>     }
> }
> test({ -> 'works' } as I)
> {code}
> Reports "Cannot find matching method script#accept(java.lang.Object)".



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