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 2022/02/23 20:41:00 UTC

[jira] [Updated] (GROOVY-9516) Static compiler infers wrong type for implicitly shared variables

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

Eric Milles updated GROOVY-9516:
--------------------------------
    Fix Version/s: 2.5.16

> Static compiler infers wrong type for implicitly shared variables
> -----------------------------------------------------------------
>
>                 Key: GROOVY-9516
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9516
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 3.0.0, 2.5.11
>            Reporter: Konstantin Nisht
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 4.0.0-alpha-1, 3.0.5, 2.5.16
>
>
> Consider the following code
> {code:groovy}
> class A {}
> class B extends A{ def b() {}}
> class C extends A{}
> @CompileStatic
> static foo() {
>   def x = new B()
>   ({ x = new C() })()
>   def z = x
>   z.b()
> }
> {code}
> Here type of {{z}} in the last line of the method is deduced to be {{B}}. Attempt to execute {{z.b()}} leads to cast exception, which is unexpected under static compilation.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)