<div dir="ltr">So there is a special case for permits clause, but what about extends clause? Should I also look into it, or, formally, this is a different issue that requires (arguably) JLS change?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Aug 26, 2024 at 4:51 PM Maurizio Cimadamore <<a href="mailto:maurizio.cimadamore@oracle.com">maurizio.cimadamore@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"><u></u>

  
  <div>
    <p><br>
    </p>
    <div>On 26/08/2024 14:44, Maurizio
      Cimadamore wrote:<br>
    </div>
    <blockquote type="cite">That
      is, an “extends” or “permits” clause is not really type-checked as
      if inside the body of class C. This results in the accessibility
      problem you point out (which might or might not be a compiler
      glitch, I don’t think the JLS is crystal clear on how Tmp.A should
      be checked).</blockquote>
    <p>I stand corrected - see JLS 6.6:</p>
    <p>
      </p><blockquote type="cite">A member (class, interface, field, or
        method) of a class, interface, type parameter, or reference
        type, or a constructor of a class, is accessible only if (i) the
        class, interface, type parameter, or reference type is
        accessible, and (ii) the member or constructor is declared to
        permit access: <br>
        [...]<br>
        <div>
          <ul style="list-style-type:circle">
            <li>
              <p> Otherwise, the member or
                constructor is declared <code>private</code>.
                Access is permitted only when one of the following is
                true: </p>
              <div>
                <ul style="list-style-type:square">
                  <li>
                    <p>Access occurs from within the
                      body of the top level class or interface that
                      encloses the declaration of the member or
                      constructor. </p>
                  </li>
                  <li> Access occurs in the <code>permits</code> clause of the top
                    level class or interface that encloses the
                    declaration of the member. </li>
                  <li>
                    <p>Access occurs in the record
                      component list of the top level record class that
                      encloses the declaration of the member. </p>
                  </li>
                </ul>
              </div>
            </li>
          </ul>
        </div>
      </blockquote>
      So, there's special accessibility pleads for "permits" clauses. So
      yes, this is a javac bug.<p></p>
    <p>I've added some comments to JDK-8338981.</p>
    <p>Maurizio<br>
    </p>
  </div>

</blockquote></div>