JEP325: Switch expressions spec

Brian Goetz brian.goetz at oracle.com
Wed Apr 18 19:30:23 UTC 2018


All good points.  Minor comments inline.

> |Were we considering allowing `case /something/, default:` or 
> `default, case /something/:`? Of course you would never ever actually 
> /need/ this... except in the one case that /something/ is null. In a 
> switch expression it would be sad to be forced to revert to the old 
> syntax for only this reason.|

|This may well be needed, especially if we prohibit fallthrough from a 
colon label into a arrow label.

Another case where a simliar problem arises is this:

     case null:
     case String s:
         // whoops, s is not DA here

Really, we'd like to say

     case null s, String s:

or

     case (null | String) s:

or something similar.  We don't have to cross this until we get to type 
patterns, but it's on the horizon.

|
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20180418/6a8c2b0c/attachment.html>


More information about the amber-spec-experts mailing list