[ 
https://issues.apache.org/jira/browse/GROOVY-9516?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17090347#comment-17090347
 ] 

Jochen Theodorou commented on GROOVY-9516:
------------------------------------------

Eric, would  it not be better to handle this like an if-else and eval the type 
of z to A here?

> 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
>            Priority: Major
>
> 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.3.4#803005)

Reply via email to