You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/03/15 13:36:00 UTC

[jira] [Resolved] (GROOVY-9972) LUB does not work correctly in case of ternary operator

     [ https://issues.apache.org/jira/browse/GROOVY-9972?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles resolved GROOVY-9972.
---------------------------------
    Fix Version/s: 4.0.0-alpha-3
       Resolution: Fixed

> 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
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 4.0.0-alpha-3
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> 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)