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 2022/08/30 14:22:00 UTC
[jira] [Comment Edited] (GROOVY-10294) Variable's inferred type is upcasted to an Object
[ https://issues.apache.org/jira/browse/GROOVY-10294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17436393#comment-17436393 ]
Eric Milles edited comment on GROOVY-10294 at 8/30/22 2:21 PM:
---------------------------------------------------------------
{-}https://github.com/apache/groovy/commit/c59a02ad15b9b9fd7548860d51fc7f7e643bb12f{-}
https://github.com/apache/groovy/commit/e7e6356ac2045dc5100c6a03e87d8d9947774dcf
was (Author: emilles):
https://github.com/apache/groovy/commit/c59a02ad15b9b9fd7548860d51fc7f7e643bb12f
> 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.10#820010)