<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <font size="4" face="monospace">Correct.  In your second example,
      neither JE is in scope.  The simple rule about pattern scoping is
      that a pattern variable is in scope where it would be definitely
      assigned.  (The definite assignment rules look complicated in the
      spec, but they are the obvious rules of "I couldn't get here
      without having been through here first" that we all run when we
      simulate Java code in our heads.)  So in <br>
      <br>
          if (x instanceof Foo f || x instanceof Bar b) { ... }<br>
      <br>
      neither f nor b are in scope inside the block, because neither is
      definitely assigned when we get to the block.  (We may know that
      one of the two patterns matched if we get into the block (in fact,
      exactly one), but because we have no idea which one, we cannot
      conclude that either pattern variable is definitely assigned.)<br>
    </font><br>
    <div class="moz-cite-prefix">On 2/19/2024 1:19 AM, Charles wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CAN5K7+tmNYDMCser_VoFdaAUpcX2ew28id_e12DB85AHvKuZ+w@mail.gmail.com">
      
      <div dir="ltr">
        <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:#000000">Hi
          Brian</div>
        <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:#000000"><br>
        </div>
        <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:#000000">Thanks
          for clarifying. I suppose the second case, which uses two
          separate variables, is also explained by that. </div>
        <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:#000000"><br>
        </div>
        <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:#000000">Since
          pattern matching doesn't differentiate which "je" got created,
          it can't tell which variable will eventually be visible in the
          scope. Hence it is saying both variables are not visible in
          the scope.</div>
        <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:#000000"><br>
        </div>
        <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:#000000"><br>
        </div>
        <div>
          <div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">
            <div dir="ltr">
              <div>
                <div dir="ltr">
                  <div dir="ltr">
                    <div dir="ltr">
                      <div dir="ltr">
                        <div dir="ltr">
                          <div dir="ltr">
                            <div dir="ltr">
                              <div dir="ltr">
                                <div dir="ltr">
                                  <div dir="ltr">
                                    <div dir="ltr">
                                      <div dir="ltr">
                                        <div dir="ltr">
                                          <div dir="ltr">
                                            <div dir="ltr">
                                              <div dir="ltr">
                                                <div dir="ltr"><font color="#000000"><br>
                                                  </font></div>
                                                <div dir="ltr"><font color="#000000"><br>
                                                  </font></div>
                                                <div dir="ltr"><span style="font-size:12.8000001907349px"><font color="#000000">and as
                                                      always, have a
                                                      great
                                                      day                                  
                                                      <br>
                                                    </font></span></div>
                                                <div dir="ltr"><b style="font-size:12.8000001907349px"><font color="#000000"><br>
                                                    </font></b></div>
                                                <div dir="ltr"><b><font color="#000000">Best
                                                      Regards<br>
                                                    </font></b>
                                                  <div><font face="arial, helvetica, sans-serif" color="#000000"><b>Charles</b></font></div>
                                                  <div><b><font style="background-color:rgb(255,255,255)" face="arial, helvetica, sans-serif" color="#000000"><br>
                                                      </font></b></div>
                                                  <div>
                                                    <p style="margin:0cm 0cm 0.0001pt"><br>
                                                    </p>
                                                  </div>
                                                </div>
                                              </div>
                                            </div>
                                          </div>
                                        </div>
                                      </div>
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <br>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Sun, Feb 18, 2024 at
          11:33 PM Brian Goetz <<a href="mailto:brian.goetz@oracle.com" moz-do-not-send="true" class="moz-txt-link-freetext">brian.goetz@oracle.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> <font size="4" face="monospace">This is not a bug; this
              potential feature was discussed at some length during the
              design process.  Another way this potential-feature could
              show up is:<br>
              <br>
                  switch (container) { <br>
                      case Box(String s), Bag(String s): ... use s ...<br>
                  }<br>
              <br>
              The reason that we chose not to proceed with such "binding
              merging" is that when you get inside the block, `je` is
              one variable with two declarations; you don't really know
              where the declaration is.  (So IDE navigations like "go to
              declaration" would have to learn to highlight TWO (or
              more) declarations, for example.)<br>
              <br>
              This feature isn't fundamentally impossible, and we could
              consider it again in the future, but it was a deliberate
              decision to not go this far at this time.<br>
              <br>
            </font><br>
            <div>On 2/18/2024 6:53 AM, Charles wrote:<br>
            </div>
            <blockquote type="cite">
              <div dir="ltr">
                <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">Hi
                  all</div>
                <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"><br>
                </div>
                <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"><br>
                </div>
                <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">What
                  I'm about to report below is <b>openjdk 17</b>. </div>
                <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"><br>
                </div>
                <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"><br>
                </div>
                <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">This
                  doesn't compile</div>
                <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"><br>
                </div>
                <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><font color="#38761d">if (ex instanceof JedisException je<br>
                                                || (ex instanceof
                    ExecutionException ee && ee.getCause()
                    instanceof JedisException je)<br>
                                ){<br>
                  </font></div>
                <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><font color="#38761d">   ... blah blah</font></div>
                <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><font color="#38761d">}</font></div>
                <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"><br>
                </div>
                <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">reason
                  being the second je is already defined in the scope. </div>
                <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"><img src="cid:part1.0PkWveSv.pzB0Lwtb@oracle.com" alt="image.png" class="" width="562" height="58"><br>
                </div>
                <div>
                  <div dir="ltr" class="gmail_signature">
                    <div dir="ltr">
                      <div dir="ltr">
                        <div dir="ltr">
                          <div dir="ltr">
                            <div dir="ltr">
                              <div dir="ltr">
                                <div dir="ltr">
                                  <div dir="ltr">
                                    <div dir="ltr">
                                      <div dir="ltr">
                                        <div dir="ltr">
                                          <div dir="ltr">
                                            <div dir="ltr">
                                              <div dir="ltr">
                                                <div dir="ltr">
                                                  <div dir="ltr">
                                                    <div dir="ltr">
                                                      <div dir="ltr"><font color="#000000"><br>
                                                        </font></div>
                                                      <div>
                                                        <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">if
                                                          you think
                                                          about it. if
                                                          ex is je,
                                                          then, the
                                                          second part
                                                          won't trigger.
                                                          And if the
                                                          second part is
                                                          reached, then
                                                          ex is not je.
                                                          Hence there is
                                                          only going to
                                                          be one
                                                          statement
                                                          mapped to je. </div>
                                                        <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">no
                                                          confusion
                                                          here. I feel
                                                          this should be
                                                          allowed. </div>
                                                        <br>
                                                      </div>
                                                      <div><br>
                                                      </div>
                                                      <div>
                                                        <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">Let's
                                                          assume the
                                                          above is the
                                                          way it should
                                                          be. I
                                                          use different
                                                          names for the
                                                          second
                                                          variable. </div>
                                                        <br>
                                                      </div>
                                                      <div><font color="#38761d"> if (ex instanceof JedisException je<br>
                                                                       
                                                                || (ex
                                                          instanceof
                                                          ExecutionException
                                                          ee &&
                                                          ee.getCause()
                                                          instanceof
                                                          JedisException
                                                          second_je)<br>
                                                                      )
                                                          {<br>
                                                                       
                                                           
                                                          log.error(je);<br>
                                                                       
                                                           
                                                          log.error(second_je);<br>
                                                                      }</font><br>
                                                      </div>
                                                      <div><br>
                                                      </div>
                                                      <div><img src="cid:part2.KFWlMpFD.bBXdYtEJ@oracle.com" alt="image.png" class="" width="562" height="94"><br>
                                                      </div>
                                                      <div>
                                                        <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">This
                                                          still doesn't
                                                          compile. </div>
                                                        <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"><br>
                                                        </div>
                                                        <div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">I
                                                          would like to
                                                          bring this
                                                          issue up for
                                                          discussion. </div>
                                                        <br>
                                                      </div>
                                                      <div><br>
                                                      </div>
                                                      <div><br>
                                                      </div>
                                                      <div><br>
                                                      </div>
                                                      <div dir="ltr"><span style="font-size:12.8px"><font color="#000000">and as always, have a
                                                          great
day                                   <br>
                                                          </font></span></div>
                                                      <div dir="ltr"><b style="font-size:12.8px"><font color="#000000"><br>
                                                          </font></b></div>
                                                      <div dir="ltr"><b><font color="#000000">Best Regards<br>
                                                          </font></b>
                                                        <div><font face="arial, helvetica, sans-serif" color="#000000"><b>Charles</b></font></div>
                                                        <div><b><font style="background-color:rgb(255,255,255)" face="arial, helvetica, sans-serif" color="#000000"><br>
                                                          </font></b></div>
                                                        <div>
                                                          <p style="margin:0cm 0cm 0.0001pt"><br>
                                                          </p>
                                                        </div>
                                                      </div>
                                                    </div>
                                                  </div>
                                                </div>
                                              </div>
                                            </div>
                                          </div>
                                        </div>
                                      </div>
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </blockquote>
            <br>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <br>
  </body>
</html>