[
https://issues.apache.org/jira/browse/GROOVY-10098?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles updated GROOVY-10098:
---------------------------------
Fix Version/s: 2.5.19
> 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-1, 3.0.9, 2.5.19
>
>
> 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.20.10#820010)