Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.6-beta-1
-
Fix Version/s: 1.5.7, 1.6-beta-2
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
Given these Java interfaces:
import java.util.List; public interface Base { List foo(); }
import java.util.ArrayList; public interface Child extends Base { ArrayList foo(); }
Java allows the return type for methods to be the most specified or a derived type:
import java.util.ArrayList; public class JavaChildImpl implements Child { public ArrayList foo() { return null; } }
But compiling this Groovy script:
class GroovyChildImpl implements Child { public ArrayList foo() { return null } }
yields:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, GroovyChildImpl.groovy: 2: the return type is incompatible with java.util.List foo() in Base.
Node: org.codehaus.groovy.ast.MethodNode. At [2:5] @ line 2, column 5.
public ArrayList foo() {
^
1 error
Attached patch fixes this problem.
I guess the check (if it is allowed and if a bridge method has to be added) respects super classes, but not interfaces being implemented by the current class.