Daniil Ovchinnikov created GROOVY-8022:
------------------------------------------

             Summary: Plus assignment for unusual property
                 Key: GROOVY-8022
                 URL: https://issues.apache.org/jira/browse/GROOVY-8022
             Project: Groovy
          Issue Type: Bug
          Components: Static Type Checker
    Affects Versions: 2.4.7
            Reporter: Daniil Ovchinnikov


{code}
class A {
    C plus(B b) {
        println "plus"
        new C()
    }
}

class B {}

class C {}

class Foo {
    A getProp() {
        println "get"
        new A()
    }

    void setProp(C c) {
        println "set"
    }
}

@CompileStatic
class Main {
    static void main(String[] args) {
        def foo = new Foo()
        foo.prop += new B()
    }
}
{code}

Correctly prints without @CompileStatic:
{noformat}
get
plus
set
{noformat}

With @CompileStatic fails with:
{noformat}
Error:(32, 9) Groovyc: 
[Static type checking] - Cannot assign value of type B to variable of type C
{noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to