Daniil Ovchinnikov created GROOVY-8157:
------------------------------------------

             Summary: 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() {} }
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}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to