I'm going to take a picture in the dark here without reading any reason for this, but if this is not the main reason for the behavior, this is at least the reason.
Suppose the enumeration instead comes from the library your project depends on. In the version you are compiling, ONE and TWO are the only parameters. However, you can work with a later version (via OSGi or other solutions) that added a different value to THREE . If THREE is passed to fooToInt , it will reach the end of your method and nothing will be returned (or selected). Unfortunately.
This is pretty unpleasant to detect at runtime, so you have to make choices about how this will be handled, even if it really seems impossible at compile time. Some cases, for example, in your example, can be detected and resolved for compilation, while in other cases it could be handled differently (for example, an implicit throw ), but in the list of all things that could be done to improve Java, I would not say that upstairs.
source share