Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.0.11
-
None
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.
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) } }
A workaround is to declare a getter and setter in the superclass.
Attachments
Issue Links
- causes
-
GROOVY-11044 SC: property access within closure produces cast exception
- Closed