[
https://issues.apache.org/jira/browse/GROOVY-10294?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Paul King closed GROOVY-10294.
------------------------------
> Variable's inferred type is upcasted to an Object
> -------------------------------------------------
>
> Key: GROOVY-10294
> URL: https://issues.apache.org/jira/browse/GROOVY-10294
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Reporter: Thodoris Sotiropoulos
> Assignee: Eric Milles
> Priority: Major
> Fix For: 4.0.0-beta-2
>
>
> I am not sure if this is a bug or a feature (or a general limitation of flow
> typing employed by Groovy).
> I have the following program
> {code:java}
> class A {
> A foo() {
> def x = new A()
> if (false) {
> x = null
> }
> x
> }
> }
> {code}
> h3. Actual behavior
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
> failed:
> test.groovy: 7: [Static type checking] - Cannot return value of type
> java.lang.Object on method returning type A
> @ line 7, column 5.
> x
> ^
> 1 error
> {code}
> h3. Expected behaviour
> Compile successfully
> Tested against master
--
This message was sent by Atlassian Jira
(v8.20.1#820001)