Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
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
- is duplicated by
-
GROOVY-9470 Automatic type casting with switch..case with instanceof
- Closed