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.)  




More information about the amber-spec-observers mailing list