<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style></head><body lang=FR link=blue vlink="#954F72" style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal>Hello sir,</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Thank you for your attention.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>As I recall, « switch » without explicit null cases do not accept nulls.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I enriched the failing cases here and included commands ran and their output : <a href="https://gist.github.com/grimly/1cc1228feacb51eaef59bfea86d2add5">https://gist.github.com/grimly/1cc1228feacb51eaef59bfea86d2add5</a></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>In the gist above, the « TestFailing » file throws as I would expect by the missing null case.</p><p class=MsoNormal>Adding the null case in « TestFailing2 » didn’t help either.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Best regards,</p><p class=MsoNormal>Michel</p><p class=MsoNormal><o:p> </o:p></p><div style='mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal style='border:none;padding:0cm'><b>From: </b><a href="mailto:tjmnkrajyej@gmail.com">tjmnkrajyej@gmail.com</a><br><b>Sent: </b>vendredi 23 septembre 2022 17:55<br><b>To: </b><a href="mailto:michel.turpin1@gmail.com">Michel Turpin</a>; <a href="mailto:amber-dev@openjdk.org">amber-dev@openjdk.org</a><br><b>Subject: </b>Bad exhaustive test using Record Pattern as delivered in OpenJDK 19 preview</p></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>`opt` can be `null`.<br><br><o:p></o:p></p><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><p class=MsoNormal>Hello, <o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>First, please excuse me for the way I send this bug report. I cannot find a way to report it in other ways.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Looking at the description of JEP 405, it made me think of Rust enums and pattern matching.<o:p></o:p></p></div><div><p class=MsoNormal>I tried then to play on how to write a copy of the Rust "Option" enum : <a href="https://gist.github.com/grimly/55d414f0cc3395e87a7c813176c50ac9">https://gist.github.com/grimly/55d414f0cc3395e87a7c813176c50ac9</a><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>But then I encountered this issue when narrowing the types I use and in this particular instance ( <a href="https://gist.github.com/grimly/55d414f0cc3395e87a7c813176c50ac9#file-testfailing-java-L9-L12">https://gist.github.com/grimly/55d414f0cc3395e87a7c813176c50ac9#file-testfailing-java-L9-L12</a> ), the compiler throws an error and reports the switch is not exhaustive.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Given in my code "Option" is sealed and may only be "Some" or "None", I would expect listing both options to make my cases exhaustive.<o:p></o:p></p></div><div><p class=MsoNormal>Adding a default case, I also fail to produce an instance that would trigger it.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Best regards,<o:p></o:p></p></div><div><p class=MsoNormal>Michel<o:p></o:p></p></div><div><p class=MsoNormal><br>-- <o:p></o:p></p></div></div></blockquote><p style='mso-margin-top-alt:5.0pt;margin-right:36.0pt;margin-bottom:5.0pt;margin-left:36.0pt'><span style='color:#1F497D'>Michel TURPIN</span></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>