File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
docs/_docs/reference/other-new-features Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -39,8 +39,11 @@ The precise rules are as follows:
3939 - the class has a companion object (which might have been generated in step 1), and
4040 - that companion object does not already define a member named ` apply ` .
4141
42- Each generated ` apply ` method forwards to one constructor of the class. It has the
43- same type and value parameters as the constructor.
42+ Each generated ` apply ` method forwards to one constructor of the class.
43+ It has the same type and value parameters as the constructor,
44+ as well as the same access restriction as the class.
45+ If the class is ` protected ` , then either the companion object must be ` protected `
46+ or the ` apply ` method will be made ` protected ` .
4447
4548Constructor proxy companions cannot be used as values by themselves. A proxy companion object must
4649be selected with ` apply ` (or be applied to arguments, in which case the ` apply ` is implicitly
Original file line number Diff line number Diff line change @@ -7,3 +7,12 @@ class Enumeration:
77class Test extends Enumeration :
88 val Hearts = Val (27 ) // error
99 val Diamonds = Val () // error
10+
11+ package p:
12+ private [p] class C (i : Int ) // ctor proxy gets privateWithin of class
13+ private [p] class D (i : Int )
14+ object D
15+
16+ package q:
17+ def f () = p.C (42 ) // error
18+ def g () = p.D (42 ) // error
You can’t perform that action at this time.
0 commit comments