[ https://issues.apache.org/jira/browse/GROOVY-8411?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16287159#comment-16287159 ]
Paul King commented on GROOVY-8411: ----------------------------------- This should be possible. It would need to take into account fall-through scenarios. > 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 > Priority: Minor > > 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 is the example falls in an {{@TypeChecked}} or {{@CompileStatic}} > scope, there is an error for the {{canonicalPath}} reference. -- This message was sent by Atlassian JIRA (v6.4.14#64029)