Pattern instanceof Variable JEP clarification

Brian Goetz brian.goetz at oracle.com
Tue Nov 26 15:53:34 UTC 2019


> Have a few clarifications, assuming we take the following example:
>  
> public void method foo() {
>  
>  
> if (e instanceof String s) {
>   // s allowed
> } else {
>  // s not allowed
> }
>  // A: s should not be allowed here?
> }

In this example, s is allowed at A if and only if the ELSE block never completes normally.  (In that case, in all the cases you could get to A, it is because the match succeeded, and hence s would be DA.)  


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20191126/692d6fd3/attachment.html>


More information about the amber-spec-experts mailing list