Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian Goetz briangoetz

View GitHub Profile
View gist:7650431
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?
You can’t perform that action at this time.