File tree Expand file tree Collapse file tree 3 files changed +32
-4
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 3 files changed +32
-4
lines changed Original file line number Diff line number Diff line change @@ -818,8 +818,12 @@ object SymDenotations {
818818 */
819819 final def isAccessibleFrom (pre : Type , superAccess : Boolean = false , whyNot : StringBuffer = null )(using Context ): Boolean = {
820820
821- /** Are we inside definition of `boundary`? */
822- def accessWithin (boundary : Symbol ) = ctx.owner.isContainedIn(boundary)
821+ /** Are we inside definition of `boundary`?
822+ * If this symbol is Java defined, package structure is interpreted to be flat.
823+ */
824+ def accessWithin (boundary : Symbol ) =
825+ ctx.owner.isContainedIn(boundary)
826+ && ! (is(JavaDefined ) && boundary.is(PackageClass ) && ctx.owner.enclosingPackageClass != boundary)
823827
824828 /** Are we within definition of linked class of `boundary`? */
825829 def accessWithinLinked (boundary : Symbol ) = {
@@ -2209,8 +2213,8 @@ object SymDenotations {
22092213 ensureCompleted()
22102214 myCompanion
22112215
2212- override def registeredCompanion_= (c : Symbol ) =
2213- myCompanion = c
2216+ override def registeredCompanion_= (c : Symbol ) =
2217+ myCompanion = c
22142218
22152219 private var myNestingLevel = - 1
22162220
Original file line number Diff line number Diff line change 1+ package pkg ;
2+
3+ public class A {
4+
5+ protected void fn1 () { System .out .println ("A#fn1()" ); }
6+ void fn2 () { System .out .println ("A#fn2()" ); }
7+
8+ }
Original file line number Diff line number Diff line change 1+ package pkg .sub
2+
3+ import pkg .A
4+
5+ class B extends A {
6+
7+ def test (): Unit = {
8+ super .fn1()
9+ super .fn2() // error: cannot be acesssed
10+
11+ val b : B = new B ()
12+ b.fn1()
13+ b.fn2() // error: cannot be acesssed
14+ }
15+
16+ }
You can’t perform that action at this time.
0 commit comments