Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-8411

Support instanceof-like flow typing for class literal switch case

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      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:

        switch (maybeFile) {
        case File:
          maybeFile.canonicalPath
          break
        default:
          maybeFile.toString()
        }
      

      Currently the example fails in an @TypeChecked or @CompileStatic scope, there is an error for the canonicalPath reference.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                emilles Eric Milles
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: