Thodoris Sotiropoulos created GROOVY-10158:
----------------------------------------------

             Summary: 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


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}
 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to