groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Milles (JIRA)" <j...@apache.org>
Subject [jira] [Created] (GROOVY-8411) Support instanceof-like flow typing for class literal switch case
Date Mon, 11 Dec 2017 15:58:01 GMT
Eric Milles created GROOVY-8411:
-----------------------------------

             Summary: 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)

Mime
View raw message