You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Mauro Molinari (Jira)" <ji...@apache.org> on 2021/01/26 11:29:00 UTC
[jira] [Created] (GROOVY-9909) Cannot call super when overriding an
interface default method
Mauro Molinari created GROOVY-9909:
--------------------------------------
Summary: 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
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)