[ https://issues.apache.org/jira/browse/GROOVY-10472 ]


    Paul King deleted comment on GROOVY-10472:
    ------------------------------------

was (Author: paulk):
Proposed PR merged. If you can check whether the snapshot builds work for your 
real-life example, that would be great.

> @AutoImplement is failing when covariant returns are involved
> -------------------------------------------------------------
>
>                 Key: GROOVY-10472
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10472
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>            Reporter: Phaninra
>            Assignee: Paul King
>            Priority: Major
>             Fix For: 3.0.10, 4.0.1
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> {code:java}
> @AutoImplement{code}
>  is failing when (Java) covariant returns are involved. 
>  
> Copy the following into GroovyConsole and hit run to reproduce the error.
> {code:java}
> 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{} {code}
>  
> Error will look like 
> {code:java}
> 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 {code}
>  
> 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]
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to