Skip to content

Instantly share code, notes, and snippets.

View briangoetz's full-sized avatar

Brian Goetz briangoetz

View GitHub Profile
briangoetz / gist:7650431
Created November 25, 2013 22:57
Flow typing
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?