Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.0.14, 3.0.15, 3.0.16, 3.0.17, 3.0.18, 3.0.19
Description
The following script throws Stackoverflow error when calling super.add(Object o) from overridden add(Object o) (it ends up calling itself). With @CompileDynamic on the overridden method the code works.
import groovy.transform.CompileStatic @CompileStatic class MySet extends DirtyCheckingSet { MySet(Set delegate, DirtyCheckable entity, String propertyName) { super(delegate, entity, propertyName) } @Override boolean add(Object o) { def added = super.add(o) // <-- Offending command println "Added $o" return added } } @CompileStatic class MyEntity implements DirtyCheckable { String myProperty } @CompileStatic class DirtyCheckingSet extends DirtyCheckingCollection implements Set { DirtyCheckingSet(Set target, DirtyCheckable parent, String property) { super(target, parent, property) } } @CompileStatic trait DirtyCheckable { void markDirty(String propertyName) { println "$propertyName marked dirty" } } @CompileStatic class DirtyCheckingCollection implements Collection { final @Delegate Collection target final DirtyCheckable parent final String property DirtyCheckingCollection(Collection target, DirtyCheckable parent, String property) { this.target = target this.parent = parent this.property = property } @Override boolean add(Object o) { parent.markDirty(property) target.add(o) } } MySet set = new MySet([] as Set, new MyEntity([myProperty: 'hello']), 'myProperty') set.add('myProperty')
Attachments
Issue Links
- is related to
-
GROOVY-10897 Static Type Checking selects wrong method for abstract method call check
- Closed