@@ -17,10 +17,14 @@ import Decorators._
17
17
import ast .Trees ._
18
18
import TreeTransforms ._
19
19
import java .io .File .separatorChar
20
+ import ValueClasses ._
20
21
21
22
/** Make private term members that are accessed from another class
22
23
* non-private by resetting the Private flag and expanding their name.
23
24
*
25
+ * Make private accessor in value class not-private. Ihis is necessary to unbox
26
+ * the value class when accessing it from separate compilation units
27
+ *
24
28
* Also, make non-private any private parameter forwarders that forward to an inherited
25
29
* public or protected parameter accessor with the same name as the forwarder.
26
30
* This is necessary since private methods are not allowed to have the same name
@@ -52,13 +56,18 @@ class ExpandPrivate extends MiniPhaseTransform with IdentityDenotTransformer { t
52
56
}
53
57
}
54
58
59
+ private def isVCPrivateParamAccessor (d : SymDenotation )(implicit ctx : Context ) =
60
+ d.isTerm && d.is(PrivateParamAccessor ) && isDerivedValueClass(d.owner)
61
+
55
62
/** Make private terms accessed from different classes non-private.
56
63
* Note: this happens also for accesses between class and linked module class.
57
64
* If we change the scheme at one point to make static module class computations
58
65
* static members of the companion class, we should tighten the condition below.
59
66
*/
60
67
private def ensurePrivateAccessible (d : SymDenotation )(implicit ctx : Context ) =
61
- if (d.is(PrivateTerm ) && d.owner != ctx.owner.enclosingClass) {
68
+ if (isVCPrivateParamAccessor(d))
69
+ d.ensureNotPrivate.installAfter(thisTransform)
70
+ else if (d.is(PrivateTerm ) && d.owner != ctx.owner.enclosingClass) {
62
71
// Paths `p1` and `p2` are similar if they have a common suffix that follows
63
72
// possibly different directory paths. That is, their common suffix extends
64
73
// in both cases either to the start of the path or to a file separator character.
@@ -94,6 +103,8 @@ class ExpandPrivate extends MiniPhaseTransform with IdentityDenotTransformer { t
94
103
if sym.is(PrivateParamAccessor ) && sel.symbol.is(ParamAccessor ) && sym.name == sel.symbol.name =>
95
104
sym.ensureNotPrivate.installAfter(thisTransform)
96
105
case _ =>
106
+ if (isVCPrivateParamAccessor(sym))
107
+ sym.ensureNotPrivate.installAfter(thisTransform)
97
108
}
98
109
tree
99
110
}
0 commit comments