[ 
https://issues.apache.org/jira/browse/GROOVY-10091?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul King closed GROOVY-10091.
------------------------------

> Incompatible generic argument types on closure's return type
> ------------------------------------------------------------
>
>                 Key: GROOVY-10091
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10091
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 4.0.0-beta-1
>
>
> This is related to GROOVY-10082.
> I have the following program
>  
> {code:java}
> class Foo<T> {}
> class Bar<T> extends Foo<Integer> {}
> class Baz extends Foo<Integer> {}
> public class Main {
>   public static void main(String[] args) {
>     Closure<Foo<Integer>> z = { -> new Baz()} // this works
>     Closure<Foo<Integer>> f = { -> new Bar<String>()} // this doesn't work
>   } 
> }
> {code}
>  
> h3. Actual Behaviour
>  
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> test.groovy: 9: [Static type checking] - Incompatible generic argument types. 
> Cannot assign groovy.lang.Closure<Bar<java.lang.String>> to: 
> groovy.lang.Closure<Foo<java.lang.Integer>>
>  @ line 9, column 31.
>        Closure<Foo<Integer>> f = { -> new Bar<String>()} // this doesn't work
>                                  ^1 error
> {code}
> h3. Expected Behaviour
> Compile successfully
>  
> Tested against 
> https://github.com/apache/groovy/commit/200c0eaf4c477201429fc7dbc30557952eaa54da
>  
>  
>  



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

Reply via email to