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/03/02 15:05:00 UTC
[jira] [Resolved] (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:all-tabpanel ]
Eric Milles resolved GROOVY-9934.
---------------------------------
Fix Version/s: 4.0.0-alpha-3
Resolution: Fixed
> 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
> Fix For: 4.0.0-alpha-3
>
>
> 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)