[ 
https://issues.apache.org/jira/browse/GROOVY-11029?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jason Garrett updated GROOVY-11029:
-----------------------------------
    Description: 
If a class defines a default-visibility property and a subclass declares a 
getter and a setter for that property, the subclass cannot access super's 
property.
{code:java}
import groovy.transform.CompileStatic
import spock.lang.Specification

class Foo {
    Object myThing
}

@CompileStatic  // everything works without CompileStatic
class Bar extends Foo {
    void setMyThing(Object list) {
        super.myThing = list
    }
    
    Object getMyThing() {
        return super.myThing as List  // groovy.lang.MissingPropertyException: 
No such property: myThing for class: Bar
//        return super.@myThing as List  // [Static type checking] - The field 
Foo.myThing is not accessible
    }
}

class BarTest extends Specification {
    def "myThing"() {
        when:
            Bar bar = new Bar()
            List list = []
            bar.myThing = list
        then:
            bar.myThing.is(list)
    }
}{code}
[Live 
Demo|https://gwc-experiment.appspot.com/?g=groovy_4_0&codez=eJxtUUFuwjAQPNevWHGCQ8M9EhJq1Z5KWwluiENwNolLYlv2Qogq_l7bGEgKK9mSM5OZ3VnRaGUISqPUoUvIZNIWyjTJq2q0qHFJGQnOxJllteK7pM5kmSw1clEI7mAlGeN1Zi28KwW_DFx9bX-QEzTdqhKyZCfG5gNFgOkU8ICmI0-AVpmdhVZQpfYEQ_Oz9ktmAI-EMu_7HJTIwSItzkbj6FsLS5NI8WX3Gk0Su4FZwAN4Cne_5fIm1lcwSHsj_wllFj6cUhgmJhjCWQhrHf5tlGNT93bkqH1OKXwqJ8Er0BFKLxGBSx3CpKkflTnFR87zR9brmCl1GoFXyHeOsYFnWFUIhcA694lduxYWpCLIOEfX5rbGmMSJ3aJeodO-xD3YdcwkxwJGUXE0SKqtUKbXly-_uq07M5DY-td4csWfwhR-Hw5eb27f3Q-PFuaL7hx65ETYcVj_Zao_zwXo-w]

  was:
If a class defines a default-visibility property and a subclass declares a 
getter and a setter for that property, the subclass cannot access super's 
property.
{code:java}
import groovy.transform.CompileStatic
import spock.lang.Specification

class Foo {
    Object myThing  // everything works if "public" is added
}

@CompileStatic  // everything works without CompileStatic
class Bar extends Foo {
    void setMyThing(Object list) {
        super.myThing = list
    }
    
    Object getMyThing() {
        return super.myThing as List  // groovy.lang.MissingPropertyException: 
No such property: myThing for class: Bar
//        return super.@myThing as List  // [Static type checking] - The field 
Foo.myThing is not accessible
    }
}

class BarTest extends Specification {
    def "myThing"() {
        when:
            Bar bar = new Bar()
            List list = []
            bar.myThing = list
        then:
            bar.myThing.is(list)
    }
}{code}
[Live 
Demo|https://gwc-experiment.appspot.com/?g=groovy_4_0&codez=eJxtUkFugzAQPNevWOWUHkruSJGiVu2paSsltygHYzbgBmzLNiGoyt9rOw6BlpVAMrOenZ2B10pqC4WW8tQlVlNhDlLXyYusFa9wY6nljPBrl1GSHZOKiiLZKGT8wJmDpSCEVdQYeJMSfgi4-sy-kVmou23JRQGwWACeUHc2HFupjwb4AWaqySrOZsAN0DzHnFwIWY1mT99tuS1lY2Es86rimWrAs0WRDxWdJM_BoF1fJc2jwoob-xhbfJlGoU5uupcBD-AlvIfLFXeyIYNG22jxh4gaeHdMYZnodbBxzY1x-JeWrtt2r2eGyjuawod0FKwEFaG0N9PlA2HT1K9KHOPU5NXU6F301HYKgZXIjq5jD0-wLREOHKvcO9ardqkIaYEyhk5mVmF04kLuVm_Rcd_sHv0V0ZMcXc6RcTZyqi1RpP3Jl48uc88SBLb-NH_s8Yewhc_Dwbv9_bu7MBWYL_tvwqA54WYe4r9t9QtqK_c0]


> CompileStatic: default-visible property is not accessible by a subclass that 
> defines a getter and setter
> --------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-11029
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11029
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler, Static compilation
>    Affects Versions: 4.0.11
>            Reporter: Jason Garrett
>            Priority: Major
>
> If a class defines a default-visibility property and a subclass declares a 
> getter and a setter for that property, the subclass cannot access super's 
> property.
> {code:java}
> import groovy.transform.CompileStatic
> import spock.lang.Specification
> class Foo {
>     Object myThing
> }
> @CompileStatic  // everything works without CompileStatic
> class Bar extends Foo {
>     void setMyThing(Object list) {
>         super.myThing = list
>     }
>     
>     Object getMyThing() {
>         return super.myThing as List  // 
> groovy.lang.MissingPropertyException: No such property: myThing for class: Bar
> //        return super.@myThing as List  // [Static type checking] - The 
> field Foo.myThing is not accessible
>     }
> }
> class BarTest extends Specification {
>     def "myThing"() {
>         when:
>             Bar bar = new Bar()
>             List list = []
>             bar.myThing = list
>         then:
>             bar.myThing.is(list)
>     }
> }{code}
> [Live 
> Demo|https://gwc-experiment.appspot.com/?g=groovy_4_0&codez=eJxtUUFuwjAQPNevWHGCQ8M9EhJq1Z5KWwluiENwNolLYlv2Qogq_l7bGEgKK9mSM5OZ3VnRaGUISqPUoUvIZNIWyjTJq2q0qHFJGQnOxJllteK7pM5kmSw1clEI7mAlGeN1Zi28KwW_DFx9bX-QEzTdqhKyZCfG5gNFgOkU8ICmI0-AVpmdhVZQpfYEQ_Oz9ktmAI-EMu_7HJTIwSItzkbj6FsLS5NI8WX3Gk0Su4FZwAN4Cne_5fIm1lcwSHsj_wllFj6cUhgmJhjCWQhrHf5tlGNT93bkqH1OKXwqJ8Er0BFKLxGBSx3CpKkflTnFR87zR9brmCl1GoFXyHeOsYFnWFUIhcA694lduxYWpCLIOEfX5rbGmMSJ3aJeodO-xD3YdcwkxwJGUXE0SKqtUKbXly-_uq07M5DY-td4csWfwhR-Hw5eb27f3Q-PFuaL7hx65ETYcVj_Zao_zwXo-w]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to