You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/02/10 17:43:00 UTC
[jira] [Commented] (GROOVY-9934) Bounded type parameter is not
captured by closure
[ https://issues.apache.org/jira/browse/GROOVY-9934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17282595#comment-17282595 ]
Eric Milles commented on GROOVY-9934:
-------------------------------------
This has been resolved by one of the recent fixes in Groovy 4. The necessary change has not been merged into Groovy 3 yet.
> Bounded type parameter is not captured by closure
> -------------------------------------------------
>
> Key: GROOVY-9934
> URL: https://issues.apache.org/jira/browse/GROOVY-9934
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation
> Affects Versions: 3.0.7
> Reporter: Thodoris Sotiropoulos
> Assignee: Eric Milles
> Priority: Major
>
> I have the following Groovy program
> {code:java}
> class Bar {}
> class Foo<T extends Bar> {
> public T method(T x) {
> def bar = {x}
> return bar()
> }
> }
> {code}
> h3. Actual Behavior
> The compiler raise the following compile-time error
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> Main.groovy: 6: [Static type checking] - Cannot return value of type java.lang.Object on method returning type T
> @ line 6, column 12.
> return bar()
> ^1 error
> {code}
> h3. Expected Behavior
> Compile successfully. Notably, when I remove the "extends" keyword from the type parameter, the code type checks as expected.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)