Thodoris Sotiropoulos created GROOVY-9972:
---------------------------------------------
Summary: LUB does not work correctly in case of ternary operator
Key: GROOVY-9972
URL: https://issues.apache.org/jira/browse/GROOVY-9972
Project: Groovy
Issue Type: Bug
Components: Static Type Checker
Reporter: Thodoris Sotiropoulos
I have the following program
{code:java}
class Foo {
public String x = "f";
}
class A<T> {
public T f;
A(T f) {
this.f = f;
}
}
public class Main {
public static void foo() {
def temp;
if (true) {
temp = new A<>(new Foo());
} else {
temp = new A<>(new Foo());
}
temp.f.x.toLowerCase() // works fine
}
public static void bar() {
A<Foo> temp = true ? new A<>(new Foo()) : new A<>(new Foo())
temp.f.x // does not compile;
}
}
{code}
h3. Actual Behaviour
I get the following compile-time error
{code:java}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 26: [Static type checking] - No such property: x for class:
java.lang.Object
@ line 26, column 5.
temp.f.x // does not compile;
^1 error
{code}
h3. Expected Behaviour
Compile Successfuly.
Tested on
[https://github.com/apache/groovy/commit/06e8cdeac2aa84403506b23a22c5254c5219850b]
--
This message was sent by Atlassian Jira
(v8.3.4#803005)