Daniil Ovchinnikov created GROOVY-9562:
------------------------------------------

             Summary: Base class property causes CCE
                 Key: GROOVY-9562
                 URL: https://issues.apache.org/jira/browse/GROOVY-9562
             Project: Groovy
          Issue Type: Bug
          Components: Static compilation
    Affects Versions: 2.5.11
            Reporter: Daniil Ovchinnikov


{code:title=playground.groovy}
abstract class BaseClass {
    def prop = 42
}

abstract class BaseClass2 {
    def prop = 69
}

@groovy.transform.CompileStatic
class Impl extends BaseClass {
    def usage() {
        new BaseClass2() {
            def foo() {
                prop
            }
        }
    }
}

assert new Impl().usage().foo() == 69
{code}

Output:
{noformat}
Caught: java.lang.ClassCastException: Impl$1 cannot be cast to BaseClass
java.lang.ClassCastException: Impl$1 cannot be cast to BaseClass
        at Impl$1.foo(playground.groovy)
        at Impl$1$foo.call(Unknown Source)
        at playground.run(playground.groovy:20)
{noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to