File tree 2 files changed +25
-1
lines changed
compiler/src/dotty/tools/dotc/core
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -149,9 +149,11 @@ object NamerOps:
149
149
*/
150
150
def addConstructorApplies (scope : MutableScope , cls : ClassSymbol , modcls : ClassSymbol )(using Context ): scope.type =
151
151
def proxy (constr : Symbol ): Symbol =
152
+ var flags = ApplyProxyFlags | (constr.flagsUNSAFE & AccessFlags )
153
+ if cls.is(Protected ) then flags |= Protected
152
154
newSymbol(
153
155
modcls, nme.apply,
154
- ApplyProxyFlags | (constr.flagsUNSAFE & AccessFlags ) ,
156
+ flags ,
155
157
ApplyProxyCompleter (constr),
156
158
cls.privateWithin,
157
159
constr.coord)
Original file line number Diff line number Diff line change
1
+
2
+ class A :
3
+ protected class B
4
+
5
+ // This fails to compile, as expected
6
+ val x = A ().B () // error
7
+
8
+ object C :
9
+ protected val p = " protected"
10
+ protected def getString () = " Hello!"
11
+ protected class D :
12
+ def d = D () // ok
13
+
14
+ // This fails to compile
15
+ // val y = C.p
16
+
17
+ // And this also fails to compile
18
+ // val z = C.getString()
19
+
20
+ // However, this compiles just fine.
21
+ val alpha = C .D () // error
22
+ val beta = new C .D () // error
You can’t perform that action at this time.
0 commit comments