[ https://issues.apache.org/jira/browse/GROOVY-9909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17272045#comment-17272045 ]
Mauro Molinari commented on GROOVY-9909: ---------------------------------------- I think it's not just a static type checker problem: if I remove {{@CompileDynamic}}, the first syntax gives a compiler error. The second syntax compiles, but produces a runtime error: {noformat} Caused by: groovy.lang.MissingMethodException: No signature of method: java.lang.Object.getFoo() is applicable for argument types: () values: [] at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:70) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:146) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:164) at MyClass.getFoo(MyClass.groovy:5) {noformat} I suspect it's just not supported in Groovy 2.5, but I think it would be important to get it, unless an alternative way to call the super default implementation exists. Please adjust the "Components" field of this report accordingly. > Cannot call super when overriding an interface default method > ------------------------------------------------------------- > > Key: GROOVY-9909 > URL: https://issues.apache.org/jira/browse/GROOVY-9909 > Project: Groovy > Issue Type: Bug > Components: Static compilation, Static Type Checker > Affects Versions: 2.5.14 > Reporter: Mauro Molinari > Priority: Major > > Suppose you have: > {code:java} > public interface MyInterface { > default String getFoo() { return "foo"; } > } > {code} > and a Groovy class implementing it: > {code:groovy} > @CompileStatic > class MyClass implements MyInterface { > @Overridde > String getFoo() { > return MyInterface.super.getFoo(); > } > } > {code} > This produces multiple compiler errors, like: > {noformat} > - Groovy:[Static type checking] - No such property: super for class: > java.lang.Class <MyInterface> > - Groovy:The usage of 'Class.this' and 'Class.super' is only allowed in > nested/inner classes > {noformat} > If I replace it with: > {code:groovy} > @CompileStatic > class MyClass implements MyInterface { > @Overridde > String getFoo() { > return super.getFoo(); > } > } > {code} > I get: > {noformat} > Groovy:[Static type checking] - Cannot find matching method > java.lang.Object#getFoo(). Please check if the declared type is correct and > if the method exists > {noformat} > I find no way to properly override a default method while calling the super > implementation. -- This message was sent by Atlassian Jira (v8.3.4#803005)