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/11/27 20:12:00 UTC
[jira] [Commented] (GROOVY-9931) !instanceof inference does not work
[ https://issues.apache.org/jira/browse/GROOVY-9931?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17639717#comment-17639717 ]
Eric Milles commented on GROOVY-9931:
-------------------------------------
https://github.com/apache/groovy/commit/f348e50481c24f21413c4d2b52b501b433003051
> !instanceof inference does not work
> -----------------------------------
>
> Key: GROOVY-9931
> URL: https://issues.apache.org/jira/browse/GROOVY-9931
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Affects Versions: 3.0.7
> Reporter: Stefanos Chaliasos
> Assignee: Eric Milles
> Priority: Major
>
> I have the following Groovy program
>
> {code:groovy}
> @groovy.transform.CompileStatic
> class Main {
> static Integer bar(Object o) {
> if (o !instanceof Integer) {
> return 0
> } else {
> return o
> }
> }
> }
> {code}
> h2. Actual Behavior
> The program does not compile, and I get the following error.
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> Main.groovy: 7: [Static type checking] - Cannot return value of type java.lang.Object on method returning type java.lang.Integer
> @ line 7, column 9.
> o
> ^
> 1 error
> {code}
> h2. Expected Behavior
> Compile successfully.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)