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/26 20:19:00 UTC

[jira] [Resolved] (GROOVY-8411) Support instanceof-like flow typing for class literal switch case

     [ https://issues.apache.org/jira/browse/GROOVY-8411?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles resolved GROOVY-8411.
---------------------------------
    Fix Version/s: 5.0.0-alpha-1
       Resolution: Fixed

https://github.com/apache/groovy/commit/cafdb3c5faebceb4f70f5ec1ba55d1340f2ff936

> Support instanceof-like flow typing for class literal switch case
> -----------------------------------------------------------------
>
>                 Key: GROOVY-8411
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8411
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Minor
>             Fix For: 5.0.0-alpha-1
>
>
> Would it be possible to extend the {{maybeFile instanceof File ? maybeFile.canonicalPath : maybeFile.toString()}} flow typing where {{maybeFile}} is seen as {{File}} in the true expression position to work for {{switch}}?
> This is the kind of construct I am thinking of:
> {code}
>   switch (maybeFile) {
>   case File:
>     maybeFile.canonicalPath
>     break
>   default:
>     maybeFile.toString()
>   }
> {code}
> Currently the example fails in an {{@TypeChecked}} or {{@CompileStatic}} scope, there is an error for the {{canonicalPath}} reference.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)