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 2022/04/28 11:50:00 UTC

[jira] [Created] (GROOVY-10603) LUP operation returns incorrect result

Thodoris Sotiropoulos created GROOVY-10603:
----------------------------------------------

             Summary: LUP operation returns incorrect result
                 Key: GROOVY-10603
                 URL: https://issues.apache.org/jira/browse/GROOVY-10603
             Project: Groovy
          Issue Type: Bug
          Components: Static Type Checker
            Reporter: Thodoris Sotiropoulos


I have the following program

{code}
interface Foo {}

class Bar implements Foo {}

interface Baz extends Foo {}

class Qux implements Baz {}


class Test {
  public static Foo test() {
    Qux  x = new Qux();
    return (true) ? x : (Bar) null;
    
  }
  
}
{code}

h3. Actual behaviour

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 13: [Static type checking] - Cannot return value of type groovy.lang.GroovyObject for method returning Foo
 @ line 13, column 12.
       return (true) ? x : (Bar) null;
              ^

1 error
{code}

h3. Expected behaviour

Compile successfully

Tested against master (commit: 5c468cd352f37fb5c599a3f51534ffcc55b339ed)



--
This message was sent by Atlassian Jira
(v8.20.7#820007)