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

Paul King updated GROOVY-10226:
-------------------------------
    Description: 
I have the following program:
 
{code:java}
class Foo<T> {}
class Main {
  static final <T extends Foo<String>> T test() {
    final T x = null;
    true ? (T) null: x
  }
}
{code}

h3. Actual behaviour

groovyc rejects the above program and produces

 
{code:java}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 6: [Static type checking] - Cannot return value of type 
Foo<java.lang.Object> on method returning type T
 @ line 6, column 5.
       true ? (T) null: x
       ^1 error

{code}

h3. Expected behaviour

Compile successfully

Note that if I replace the bound of type parameter `T` with a non-parameterized 
bound (e.g., Number), groovyc compiles the program as expected.
 
Tested against master
 

 

 

  was:
I have the following program

 
{code:java}
class Foo<T> {}class Main {
  static final <T extends Foo<String>> T test() {
    final T x = null;
    true ? (T) null: x
  }
}
{code}
h3. Actual behaviour

groovyc rejects the above program and produces

 
{code:java}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 6: [Static type checking] - Cannot return value of type 
Foo<java.lang.Object> on method returning type T
 @ line 6, column 5.
       true ? (T) null: x
       ^1 error

{code}
h3. Expected behaviour

Compile successfully

 

Note that if I replace the bound of type parameter `T` with a non-parameterized 
bound (e.g., Number), groovyc compiles the program as expected.

 

Tested against master

 

 

 


> LUB is computed incorrectly when involving bounded type variables
> -----------------------------------------------------------------
>
>                 Key: GROOVY-10226
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10226
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 4.0.2
>
>
> I have the following program:
>  
> {code:java}
> class Foo<T> {}
> class Main {
>   static final <T extends Foo<String>> T test() {
>     final T x = null;
>     true ? (T) null: x
>   }
> }
> {code}
> h3. Actual behaviour
> groovyc rejects the above program and produces
>  
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> test.groovy: 6: [Static type checking] - Cannot return value of type 
> Foo<java.lang.Object> on method returning type T
>  @ line 6, column 5.
>        true ? (T) null: x
>        ^1 error
> {code}
> h3. Expected behaviour
> Compile successfully
> Note that if I replace the bound of type parameter `T` with a 
> non-parameterized bound (e.g., Number), groovyc compiles the program as 
> expected.
>  
> Tested against master
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to