<div dir="ltr">Hello!<br><div><br></div><div>Another question: if we declare an exhaustive set of patterns, does it imply that they should be mutually exclusive? This is probably not so important for compiler, but could be important for IDE functions like inspections or refactorings. E.g.:</div><div><br></div><div>switch(opt) {</div><div> case Optional.of(var x) -> {...}</div><div> case Optional.empty() -> {...}</div><div>}</div><div>Is it safe to reorder branches in this switch? This is true for Optional, but can we say this for any custom set of exhaustive patterns?</div><div><br></div><div>int x = 0;</div><div>if (opt instanceof Optional.of(var x)) {x++;}</div><div>if (opt instanceof Optional.empty()) {x++;}</div><div><br></div><div>Can a static analyzer assume that only one `if` body will be visited here (i.e., x is never 2)? Again, an analyzer may hardcode this knowledge for Optional, but would it be true for any set of exhaustive patterns?</div><div><br></div><div>With kind regards,</div><div>Tagir Valeev.</div></div>