<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<font size="4" face="monospace">I don't think "exhaustiveness" need
imply "independence." As an example from the bytecode API, we
have factories for aload_0, aload(0), and load(INT, 0), all of
which produce the same bytecode. It is reasonable for a "bytecode
cursor" to have instance patterns for each of these too, and for
the sum of all the patterns for all the bytecodes to be
exhaustive, even though there is clearly overlap. <br>
</font><br>
<div class="moz-cite-prefix">On 4/4/2024 1:34 PM, Tagir Valeev
wrote:<br>
</div>
<blockquote type="cite" cite="mid:CAE+3fja_5tp=CLjTuGKwTSDDFFw4UtWXEnhf8xTMZOYq_MgsYQ@mail.gmail.com">
<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>
</blockquote>
<br>
</body>
</html>