Thodoris Sotiropoulos created GROOVY-10226:
----------------------------------------------
Summary: 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
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.3.4#803005)