This seems somewhat similar to
Consider the following interface:
and a package-private implementation:
Now the following base class:
Please note: the field is declared with the implementation type, the getter is public, but the getter declared return type is the public interface.
Then this Groovy class:
Please note the package is different.
If you run this code, the first bar is written correctly, the second invocation fails with: java.lang.IllegalAccessError: tried to access class test18.IfaceImpl from class test18.sub.Test18.
- remove @CompileStatic from Test18.foobar() (or declare it with @CompileDynamic if the whole class is statically compiled)
- change the declaration of Base.foo to be of type Iface rather than IfaceImpl