File tree 2 files changed +14
-2
lines changed
docs/_docs/reference/other-new-features
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:
39
39
- the class has a companion object (which might have been generated in step 1), and
40
40
- that companion object does not already define a member named ` apply ` .
41
41
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 ` .
44
47
45
48
Constructor proxy companions cannot be used as values by themselves. A proxy companion object must
46
49
be 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:
7
7
class Test extends Enumeration :
8
8
val Hearts = Val (27 ) // error
9
9
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