<div dir="ltr"><div class="gmail_default" style="font-family:monospace">Definitely agreed.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jul 7, 2023 at 4:34 PM Remi Forax <<a href="mailto:forax@univ-mlv.fr">forax@univ-mlv.fr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)"><div>Looks like a bug too me,<br></div><div>the possible combinations are (C, C), (C, D) (D, C) (D,D), they are all covered.</div><div><br></div><div>Rémi<br></div><div><br></div><hr id="m_2968126442153984274zwchr"><div><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><b>From: </b>"David Alayachew" <<a href="mailto:davidalayachew@gmail.com" target="_blank">davidalayachew@gmail.com</a>><br><b>To: </b>"Mikhail Pyltsin" <<a href="mailto:pyltsinm@gmail.com" target="_blank">pyltsinm@gmail.com</a>><br><b>Cc: </b>"compiler-dev" <<a href="mailto:compiler-dev@openjdk.org" target="_blank">compiler-dev@openjdk.org</a>>, "amber-dev" <<a href="mailto:amber-dev@openjdk.org" target="_blank">amber-dev@openjdk.org</a>><br><b>Sent: </b>Friday, July 7, 2023 10:43:26 PM<br><b>Subject: </b>Re: Exhaustiveness for record pattern with switch (JEP 440+441)<br></blockquote></div><div><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><div dir="ltr"><div class="gmail_default" style="font-family:monospace">I've CC'd the Amber Dev Team.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jul 7, 2023 at 1:52 PM Mikhail Pyltsin <<a href="mailto:pyltsinm@gmail.com" target="_blank">pyltsinm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi!<br>I investigated the algorithm, which Javac 21 (Build 30 (2023/7/6))</div><div>) uses to check exhaustiveness for record patterns (JEP 440+441), and found the strange behavior:<br>- let's take compilable code<br>```<br>class Test22 {<br><br> record Pair(I i1, I i2) {}<br><br> sealed interface I {}<br><br> record C() implements I {}<br><br> record D() implements I {}<br><br> void exhaustinvenessWithInterface(Pair pairI) {<br> switch (pairI) {<br> case Pair(C fst, D snd) -> {<br> }<br> case Pair(C fst, C snd) -> {<br> }<br> case Pair(I fst, C snd) -> {<br> }<br> case Pair(D fst, D snd) -> {<br> }<br> }<br> }<br>}<br>```<br>- If we swap types of components, it starts to produce the error "java: the switch statement does not cover all possible input values":<br>```<br> void exhaustinvenessWithInterface(Pair pairI) {<br> switch (pairI) {<br> case Pair(D fst, C snd) -> {<br> }<br> case Pair(C fst, C snd) -> {<br> }<br> case Pair(C fst, I snd) -> {<br> }<br> case Pair(D fst, D snd) -> {<br> }<br> }<br> }<br>```<br>It happens because Javac tries to find the first distinguished type from the beginning, but I couldn't find any mention of it in JEP.<br>Is this the expected behavior?<br><br></div></div>
</blockquote></div><br></blockquote></div></div></div></blockquote></div>