[ 
https://issues.apache.org/jira/browse/GROOVY-9909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17272074#comment-17272074
 ] 

Paul King commented on GROOVY-9909:
-----------------------------------

Probably duplicates GROOVY-9884. Yes, it's not (just) a type checker issue.

> 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)

Reply via email to