Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.5.19, 3.0.14, 2.5.20, 2.5.21
Description
In the following situation, under static compilation:
- An interface declares a getter and/or setter
- An implementing class declares a property of the corresponding name and type, so the implicit getter and/or setter implement the interface
- A subclass overrides the getter/setter and calls the super getter/setter
the subclass getter/setter will recurse instead of calling the superclass implicit method.
This appears to have been introduced in 3.0.14.
Running the main method in this example will reproduce the stack overflow.
package example import groovy.transform.CompileStatic @CompileStatic class SuperImplicitSetter { interface FooHaving { String getFoo() void setFoo(String foo) } static class Foo implements FooHaving { String foo // implements interface } static class Bar extends Foo { String bar @Override void setFoo(String foo) { super.setFoo(foo) // recurses instead of calling implicit Foo.setFoo(String) bar = foo } } static void main(String[] args) { Bar bar = new Bar() bar.setFoo("bar") // stack overflow println bar.foo } }