You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2022/07/23 16:21:00 UTC
[jira] [Updated] (GROOVY-9259) Implementing Groovy interface with default methods can cause compile issues.
[ https://issues.apache.org/jira/browse/GROOVY-9259?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-9259:
--------------------------------
Fix Version/s: (was: 5.0.0-alpha-1)
> 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
> Assignee: Eric Milles
> Priority: Minor
> Fix For: 3.0.10, 4.0.1
>
>
> 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.20.10#820010)