Compile-time type hierarchy information in pattern switch

Brian Goetz brian.goetz at
Thu Apr 5 19:44:30 UTC 2018

> Is it too harsh to reject the whole class if the assumptions on class 
> hierarchy which were necessary to compile the switch statements used 
> in the class are not valid at runtime?

That is one of the questions!  And the other question is: is this too 
expensive to do this check at runtime, given that it will fail so 

If we can detect it cheaply enough, though, we can also repair the 
situation and fall back to linear testing of patterns.  This seems 
better (we can execute the statement the user wrote) than failing. My 
real question is can I punt on trying to detect it, and still optimize 
the common cases  down to O(1) dispatch....

More information about the amber-spec-observers mailing list