You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2022/02/14 07:26:00 UTC

[jira] [Commented] (GROOVY-10472) @AutoImplement is failing when covariant returns are involved

    [ https://issues.apache.org/jira/browse/GROOVY-10472?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17491827#comment-17491827 ] 

Paul King commented on GROOVY-10472:
------------------------------------

Proposed PR:
https://github.com/apache/groovy/pull/1684

> @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)