You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "covers1624 (Jira)" <ji...@apache.org> on 2019/09/27 13:03:00 UTC
[jira] [Created] (GROOVY-9259) Implementing Groovy interface with
default methods can cause compile issues.
covers1624 created GROOVY-9259:
----------------------------------
Summary: Implementing Groovy interface with default methods can cause compile issues.
Key: GROOVY-9259
URL: https://issues.apache.org/jira/browse/GROOVY-9259
Project: Groovy
Issue Type: Bug
Affects Versions: 3.0.0-beta-3
Reporter: covers1624
Hello!
Consider the following classes.
{code:java|title=test/JavaInterface.java|borderStyle=solid}
package test;
public interface JavaInterface {
String doStuff();
}
{code}
{code:java|title=test/GroovyInterface.groovy|borderStyle=solid}
package test
interface GroovyInterface extends JavaInterface {
default doOtherStuff() {
return 'doot'
}
}
{code}
{code:java|title=test/GroovyClass.groovy|borderStyle=solid}
package test
class GroovyClass implements GroovyInterface {
@Override
String doStuff() {
return "otherDoot"
}
}
{code}
This code compiles with an error:
{noformat}
test/GroovyClass.groovy: 4: Method 'doStuff' from class 'test.GroovyClass' does not override method from its superclass or interfaces but is annotated with @Override.
@ line 4, column 5.
@Override
^
{noformat}
However, removing the default method insideĀ ~GroovyInterface~, OR, declaring ~GroovyClass~ to implement both ~GroovyInterface~ AND ~JavaInterface~ will make compilation succeed again.
Apologies if this is some form of intended behavior, although I suspect it isn't due to the nature of this issue.
Thank You for your time looking into this issue! also thanks for a fantastically flexible language!
--
This message was sent by Atlassian Jira
(v8.3.4#803005)