<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body style="word-wrap:break-word" vlink="#954F72" link="blue" lang="NL-BE">
    <font size="4"><font face="monospace">This one got stuck in the
        -comments moderation queue for a while.<br>
        <br>
        <br>
      </font></font>
    <div class="moz-forward-container"><br>
      <br>
      -------- Forwarded Message --------
      <table class="moz-email-headers-table" cellspacing="0" cellpadding="0" border="0">
        <tbody>
          <tr>
            <th valign="BASELINE" nowrap="nowrap" align="RIGHT">Subject:
            </th>
            <td>Use of "assignment compatible" in the switch statement
              specifications</td>
          </tr>
          <tr>
            <th valign="BASELINE" nowrap="nowrap" align="RIGHT">Date: </th>
            <td>Wed, 6 Jul 2022 22:29:32 +0000</td>
          </tr>
          <tr>
            <th valign="BASELINE" nowrap="nowrap" align="RIGHT">From: </th>
            <td>Robbe Pincket <a class="moz-txt-link-rfc2396E" href="mailto:robbepincket@live.be"><robbepincket@live.be></a></td>
          </tr>
          <tr>
            <th valign="BASELINE" nowrap="nowrap" align="RIGHT">To: </th>
            <td><a class="moz-txt-link-abbreviated" href="mailto:jls-jvms-spec-comments@openjdk.java.net">jls-jvms-spec-comments@openjdk.java.net</a>
              <a class="moz-txt-link-rfc2396E" href="mailto:jls-jvms-spec-comments@openjdk.java.net"><jls-jvms-spec-comments@openjdk.java.net></a>,
              <a class="moz-txt-link-abbreviated" href="mailto:amber-spec-comments@openjdk.org">amber-spec-comments@openjdk.org</a>
              <a class="moz-txt-link-rfc2396E" href="mailto:amber-spec-comments@openjdk.org"><amber-spec-comments@openjdk.org></a></td>
          </tr>
        </tbody>
      </table>
      <br>
      <br>
      
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style>@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;}p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}.MsoChpDefault
        {mso-style-type:export-only;}div.WordSection1
        {page:WordSection1;}</style>
      <div class="WordSection1">
        <p class="MsoNormal"><span lang="EN-GB">Hi experts<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">A while back I was
            reading the new amber spec on switch pattern matching, and
            read something that felt off, but after checking the normal
            spec, I noticed the issue existed there too.
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">It was late when I sent
            my review of the amber spec to their group, so I wanted to
            sent this the day after but I managed to forget it.<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">In 5.2, the concept of
            "assignment compatible" is introduced:<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">> If the type of an
            expression can be converted to the type of a variable by
            assignment conversion, we say the expression (or its value)
            is assignable to the variable or, equivalently, that the
            type of the expression is assignment compatible with the
            type of the variable.<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">It is a useful concept
            that is used a total of 16 times in the spec for java 18
            (and the current 19 spec).<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">Although this concept is
            introduced as a relation between two types, in the switch
            statement specifications (14.11) the following appears:<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">> 14.11.1 Switch
            Blocks<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">> ...<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">> The switch block of
            a switch statement or a switch expression is compatible with<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">the type of the selector
            expression, T, if both of the following are true:<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">> * If T is not an
            enum type, then **every case constant associated with the
            switch<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">block is assignment
            compatible with T (ยง5.2)**.<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">> * ...<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">Here the relation is
            used between a constant and a type, which seems to be
            incorrect.<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">For the Amber experts,
            this section has been rewritten due to there being more
            valid possible selector types, but the issue remains:<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">> A case constant c
            is switch compatible with a type T where T is either char,
            byte, short, int, Character, Byte, Short, Integer, or String
            if c is assignment compatible with T (5.2).<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">Greetings<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">Robbe Pincket</span><span lang="EN-GB"><o:p></o:p></span></p>
      </div>
    </div>
  </body>
</html>