Description
@AutoImplement
is failing when (Java) covariant returns are involved.
Copy the following into GroovyConsole and hit run to reproduce the error.
import groovy.transform.* @CompileStatic interface Super { Iterable findAll() } @CompileStatic interface Sub extends Super { List findAll() // a List instead of an Iterable } @AutoImplement @CompileStatic class ThisClassFails implements Sub{}
Error will look like
1 compilation error:
The return type of java.lang.Iterable findAll() in ThisClassFails is incompatible with java.util.List in Sub
. At [14:1] at line: 14, column: 1
Refs:
- Real life example: https://docs.spring.io/spring-data/jpa/docs/current/api/org/springframework/data/jpa/repository/JpaRepository.html Look at all variations of `findAll` methods in that interface and super - some use Iterable and some use List.
- Covariant return type : https://www.javatpoint.com/covariant-return-type