This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Proponents of "flow typing" have suggested, in code like this: | |
if (foo instanceof Bar) { | |
((Bar) foo).barMethod(); | |
} | |
"why not just" allow the developer to elide the cast to Bar? Implicit in this question is the assumption that this is a very simple feature. | |
Like everything else, the easy cases are easy. The key question to ask is, under such a scheme, if the static type of foo outside the if-block is Moo, what is the static type of foo inside the if block? |