You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2022/04/27 08:47:00 UTC
[jira] [Updated] (GROOVY-10130) Flow typing does not work when && is combinded with instanceof
[ https://issues.apache.org/jira/browse/GROOVY-10130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King updated GROOVY-10130:
-------------------------------
Fix Version/s: 4.0.2
> Flow typing does not work when && is combinded with instanceof
> --------------------------------------------------------------
>
> Key: GROOVY-10130
> URL: https://issues.apache.org/jira/browse/GROOVY-10130
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation, Static Type Checker
> Reporter: Stefanos Chaliasos
> Assignee: Eric Milles
> Priority: Major
> Fix For: 4.0.2
>
>
> I have the following Groovy program.
> {code:groovy}
> @groovy.transform.TypeChecked
> class Test {
> public void foo(Foo x) {
> ((true && x instanceof Bar)) ? new Bar[]{x} : null
> }
> }
> class Foo {}
> class Bar extends Foo {}
> {code}
> h2. Actual Behavior
> The program does not compile, and I get the following error.
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> Test.groovy: 4: [Static type checking] - Cannot convert from Foo to Bar
> @ line 4, column 46.
> instanceof Bar)) ? new Bar[]{x} : null
> ^
> 1 error
> {code}
> h2. Expected Behavior
> Compile successfully.
> h2. Comment
> This should be a regression bug because it works with 3.0.8 and 4.0.0-alpha-3.
> h2. Affected Version
> This programs have been tested with the compiler from the master (commit: 8ea882a587ce3183c95ea1bc19dfc44367dc292e).
--
This message was sent by Atlassian Jira
(v8.20.7#820007)