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 {
818
818
*/
819
819
final def isAccessibleFrom (pre : Type , superAccess : Boolean = false , whyNot : StringBuffer = null )(using Context ): Boolean = {
820
820
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)
823
827
824
828
/** Are we within definition of linked class of `boundary`? */
825
829
def accessWithinLinked (boundary : Symbol ) = {
@@ -2209,8 +2213,8 @@ object SymDenotations {
2209
2213
ensureCompleted()
2210
2214
myCompanion
2211
2215
2212
- override def registeredCompanion_= (c : Symbol ) =
2213
- myCompanion = c
2216
+ override def registeredCompanion_= (c : Symbol ) =
2217
+ myCompanion = c
2214
2218
2215
2219
private var myNestingLevel = - 1
2216
2220
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