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

Thodoris Sotiropoulos updated GROOVY-9934:
------------------------------------------
    Description: 
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.

 

  was:
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.

 


> 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
>            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)

Reply via email to