You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Thodoris Sotiropoulos (Jira)" <ji...@apache.org> on 2021/09/27 12:11:00 UTC
[jira] [Created] (GROOVY-10264) Issue with the diamond operator and
conditional
Thodoris Sotiropoulos created GROOVY-10264:
----------------------------------------------
Summary: Issue with the diamond operator and conditional
Key: GROOVY-10264
URL: https://issues.apache.org/jira/browse/GROOVY-10264
Project: Groovy
Issue Type: Bug
Components: Static Type Checker
Reporter: Thodoris Sotiropoulos
I have the following program
{code:java}
class A<T extends Number> {
T foo() {
T x = null;
(true) ?
new B<>(x).f: new B<>(x).f
}
}
class B<X> {
X f;
B(X x) {
this.f = f;
}
}
{code}
h3. Actual behaviour
{code:java}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 4: [Static type checking] - Cannot return value of type java.lang.Object on method returning type T
@ line 4, column 5.
(true) ?
^1 error
{code}
h3. Expected Behaviour
Compile successfuly
Tested against master (https://github.com/apache/groovy/commit/2a97313250875d60df82302f31d77dd7f07ae685)
--
This message was sent by Atlassian Jira
(v8.3.4#803005)