Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
I have the following program
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; } }
Actual Behaviour
I get the following compile-time error
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
Expected Behaviour
Compile Successfuly.
Tested on https://github.com/apache/groovy/commit/06e8cdeac2aa84403506b23a22c5254c5219850b
Attachments
Issue Links
- relates to
-
GROOVY-7507 Cannot assign value of type java.lang.Object in ternary operator with null
- Closed