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

Eric Milles resolved GROOVY-10098.
----------------------------------
    Fix Version/s: 4.0.0-beta-2
       Resolution: Fixed

> Unexpected behaviour when the return type of a closure is a type parameter
> --------------------------------------------------------------------------
>
>                 Key: GROOVY-10098
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10098
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 4.0.0-beta-2
>
>
> This may be a recent regression.
> I have the following program
> {code:java}
> class Foo<T extends Number> {
>   T f  Foo(T f) {
>     this.f = f
>   }
>   T foo() {
>     Closure<T> clos = { -> f}
>     clos()
>   }
> }
> {code}
> h3. Actual behaviour
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> test.groovy: 10: [Static type checking] - Cannot return value of type 
> java.lang.Object on method returning type T
>  @ line 10, column 5.
>        clos()
>        ^1 error
> {code}
> h3. Expected behaviour
> Compile successfully
> h3. Comment
> The code works as expected if I remove the bound from the type parameter of 
> class `Foo`.
>  
> Tested against 
> https://github.com/apache/groovy/commit/f3d030afaaae44eca567ead74e68efb932831b08



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to