Details
Description
Given the following files:
pkg/Base.java
package pkg; public interface Base { Base doSomething(); }
pkg/Child.java
package pkg; public interface Child extends Base { Child doSomething(); }
pkg/GChild.groovy
package pkg; class GChild implements Child { Child doSomething() { return this } }
When I try to compile this, groovyc complains about incompatible return types:
$ javac pkg/*.java
$ groovyc pkg/*.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
pkg/GChild.groovy: 3: The return type of pkg.Child doSomething() in pkg.GChild is incompatible with pkg.Base doSomething() in pkg.Base
. At [3:2] @ line 3, column 2.
Child doSomething() {
^
1 error
$ javac -version
javac 1.6.0_31
$ groovyc -version
Groovy compiler version 1.8.6
Copyright 2003-2011 The Codehaus. http://groovy.codehaus.org/
$
A very similar (almost identical) issue has already been reported here: https://jira.codehaus.org/browse/GROOVY-2829 (marked as fixed in 1.5.7 and 1.6-beta2)
Playing around with the example, I found that really needs to be this situation to reproduce the problem:
As a workaround, I can do the following if returning GChild isn't an option: