[
https://issues.apache.org/jira/browse/GROOVY-8157?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Daniil Ovchinnikov updated GROOVY-8157:
---------------------------------------
Description:
{code}
import groovy.transform.CompileStatic
class A {}
class B extends A { def bbb() {} }
@CompileStatic
def fooLocalAssignment() {
A a = new B()
a.bbb()
}
@CompileStatic
def fooParameterAssignment(A a) {
a = new B()
a.bbb() // Cannot find matching method A#bbb()
}
{code}
was:
{code}
import groovy.transform.CompileStatic
class A {}
class B extends A { def bbb() {} }
interface I { A getA() }
@CompileStatic
def fooLocalInstanceof(I i) {
A a = i.getA()
if (a instanceof B) {
a.bbb()
}
}
@CompileStatic
def fooParameterInstanceof(A a) {
if (a instanceof B) {
a.bbb()
}
}
@CompileStatic
def fooLocalAssignment() {
A a = new B()
a.bbb()
}
@CompileStatic
def fooParameterAssignment(A a) {
a = new B()
a.bbb() // Cannot find matching method A#bbb()
}
{code}
> Flow typing doesn't work with assignment to a parameter
> -------------------------------------------------------
>
> Key: GROOVY-8157
> URL: https://issues.apache.org/jira/browse/GROOVY-8157
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Affects Versions: 2.4.10
> Reporter: Daniil Ovchinnikov
>
> {code}
> import groovy.transform.CompileStatic
> class A {}
> class B extends A { def bbb() {} }
> @CompileStatic
> def fooLocalAssignment() {
> A a = new B()
> a.bbb()
> }
> @CompileStatic
> def fooParameterAssignment(A a) {
> a = new B()
> a.bbb() // Cannot find matching method A#bbb()
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)