Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.6-beta-1
-
None
-
None
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.