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 2020/12/31 22:18:00 UTC

[jira] [Updated] (GROOVY-9769) STC: UnionTypeClassNode created for simple instanceof scenarios

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

Eric Milles updated GROOVY-9769:
--------------------------------
    Fix Version/s: 2.5.15

> STC: UnionTypeClassNode created for simple instanceof scenarios
> ---------------------------------------------------------------
>
>                 Key: GROOVY-9769
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9769
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Minor
>             Fix For: 3.0.7, 4.0.0-alpha-2, 2.5.15
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Consider the following:
> {code:groovy}
> interface A {
>   def foo() {}
> }
> interface B extends A {
>   def bar() {}
> }
> @groovy.transform.CompileStatic
> void test(A a) {
>   if (a instanceof B) {
>     a.foo()
>     a.bar()
>   }
> }
> {code}
> Variable expression "a" infers to "<UnionType:A+B>" due to {{instanceof}} screening.  Since B extends A, a simple ClassNode for B should be sufficient.
> The union types are harder to deal with for consumers.  This is a variant of GROOVY-7333.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)