You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2022/04/27 08:45:00 UTC
[jira] [Updated] (GROOVY-10158) Unexpected type mismatch when combining conditional and bounded type parameter
[ https://issues.apache.org/jira/browse/GROOVY-10158?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King updated GROOVY-10158:
-------------------------------
Description:
I have the following program
{code:java}
class A<T> {}
class B<T extends A<String>> {
T m() {
final T x = null;
final T y = null;
(true) ? y : x
}
}
{code}
h3. Actual Behaviour
groovyc rejects the program with
{code:java}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 7: [Static type checking] - Cannot return value of type A<java.lang.Object> on method returning type T
@ line 7, column 5.
(true) ? y : x
^1 error
{code}
h3. Expected Behaviour
Compile successfully
Tested against master
was:
I have the following program
{code:java}
class A<T> {}
class B<T extends A<String>> {
T m() {
final T x = null;
final T y = null;
(true) ? y : x
}
}
{code}
h3. Actual Behaviour
groovyc rejects the program with
{code:java}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 7: [Static type checking] - Cannot return value of type A<java.lang.Object> on method returning type T
@ line 7, column 5.
(true) ? y : x
^1 error
{code}
h3. Expected Behaviour
Compile successfully
Tested against master
{code:java}
{code}
> Unexpected type mismatch when combining conditional and bounded type parameter
> ------------------------------------------------------------------------------
>
> Key: GROOVY-10158
> URL: https://issues.apache.org/jira/browse/GROOVY-10158
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Reporter: Thodoris Sotiropoulos
> Assignee: Eric Milles
> Priority: Major
>
> I have the following program
>
> {code:java}
> class A<T> {}
> class B<T extends A<String>> {
> T m() {
> final T x = null;
> final T y = null;
> (true) ? y : x
> }
> }
> {code}
>
> h3. Actual Behaviour
> groovyc rejects the program with
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> test.groovy: 7: [Static type checking] - Cannot return value of type A<java.lang.Object> on method returning type T
> @ line 7, column 5.
> (true) ? y : x
> ^1 error
> {code}
> h3. Expected Behaviour
> Compile successfully
> Tested against master
>
--
This message was sent by Atlassian Jira
(v8.20.7#820007)