You basically want when to do the full blown pattern matching that Scala offers, but that is one of the features that JB decided was too complex (and probably really hard to implement).
While this will technically work it is not very efficient as it creates throw away objects for comparing.
I certainly agree that there are some definitely needed improvements to when, I don’t think we want full blown pattern matching.