File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed
compiler/src/dotty/tools/dotc/transform
tests/run/i17021.ext-java Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ object ProtectedAccessors {
38
38
sym.isTerm && sym.is(Protected ) &&
39
39
! sym.owner.is(Trait ) && // trait methods need to be handled specially, are currently always public
40
40
! insideBoundaryOf(sym) &&
41
- ! ctx.owner.enclosingClass.derivesFrom(sym.owner)
41
+ (sym.is( JavaDefined ) || ! ctx.owner.enclosingClass.derivesFrom(sym.owner) )
42
42
}
43
43
44
44
class ProtectedAccessors extends MiniPhase {
Original file line number Diff line number Diff line change
1
+ // Derives from run/i17021.defs, but with a Java protected member
2
+ package p1 ;
3
+
4
+ public class A {
5
+ protected int foo () { return 1 ; }
6
+ }
Original file line number Diff line number Diff line change
1
+ // Derives from run/i17021.defs
2
+ // but with a Java protected member
3
+ // which changes the behaviour
4
+ package p2:
5
+ trait B extends p1.A :
6
+ def bar : Int = foo
7
+
8
+ class C extends B :
9
+ override def foo : Int = 2
10
+
11
+ object Test :
12
+ def main (args : Array [String ]): Unit =
13
+ val n = new p2.C ().bar
14
+ assert(n == 1 , n) // B can only call super.foo
You can’t perform that action at this time.
0 commit comments