[ 
https://issues.apache.org/jira/browse/GROOVY-9909?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul King closed GROOVY-9909.
-----------------------------

> 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
>            Assignee: Eric Milles
>            Priority: Major
>              Labels: default-methods
>             Fix For: 4.0.0-rc-2
>
>
> 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.20.1#820001)

Reply via email to