You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Konstantin Nisht (Jira)" <ji...@apache.org> on 2020/04/20 09:44:00 UTC
[jira] [Created] (GROOVY-9516) Static compiler infers wrong type
for implicitly shared variables
Konstantin Nisht created GROOVY-9516:
----------------------------------------
Summary: 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: 2.5.11, 3.0.0
Reporter: Konstantin Nisht
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)