Skip to content

Commit ab59cf4

Browse files
committed
Fix isJvmAccessible returns true if the protected class is accessible
fix #24507 but I'm concerned about the comment > // We can't rely on `isContainedWith` here because packages are > // not nested from the JVM point of view.
1 parent b2850be commit ab59cf4

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

compiler/src/dotty/tools/dotc/transform/Erasure.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,8 @@ object Erasure {
753753
// not nested from the JVM point of view.
754754
val boundary = cls.accessBoundary(cls.owner)(using preErasureCtx)
755755
(boundary eq defn.RootClass) ||
756-
(ctx.owner.enclosingPackageClass eq boundary)
756+
(ctx.owner.enclosingPackageClass eq boundary) ||
757+
(cls.is(Flags.Protected) && cls.isAccessibleFrom(ctx.owner.enclosingClass.thisType)(using preErasureCtx))
757758
}
758759

759760
@tailrec

tests/pos/i24507.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Test extends javax.swing.JFrame { class Acc extends AccessibleJFrame }
2+

0 commit comments

Comments
 (0)