File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -149,9 +149,11 @@ object NamerOps:
149149 */
150150 def addConstructorApplies (scope : MutableScope , cls : ClassSymbol , modcls : ClassSymbol )(using Context ): scope.type =
151151 def proxy (constr : Symbol ): Symbol =
152+ var flags = ApplyProxyFlags | (constr.flagsUNSAFE & AccessFlags )
153+ if cls.is(Protected ) then flags |= Protected
152154 newSymbol(
153155 modcls, nme.apply,
154- ApplyProxyFlags | (constr.flagsUNSAFE & AccessFlags ) ,
156+ flags ,
155157 ApplyProxyCompleter (constr),
156158 cls.privateWithin,
157159 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