diff options
author | VladimirNik <vladimir.nikolaev9@gmail.com> | 2016-06-02 15:37:22 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-07-27 19:28:36 +0200 |
commit | 216511fb74af60369c6049e0380b39898cf55e0a (patch) | |
tree | 3cb6d59fe54f0740956555378fd86b9e71fe3c47 /src | |
parent | 855bdcc5210402fbb87ce10fe7da3f532fa3049f (diff) | |
download | dotty-216511fb74af60369c6049e0380b39898cf55e0a.tar.gz dotty-216511fb74af60369c6049e0380b39898cf55e0a.tar.bz2 dotty-216511fb74af60369c6049e0380b39898cf55e0a.zip |
Make private accessor in value class not-private.
This is necessary to unbox the value class when accessing it from
separate compilation units
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/transform/ExpandPrivate.scala | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/transform/ExpandPrivate.scala b/src/dotty/tools/dotc/transform/ExpandPrivate.scala index 2e0759b89..83cd395ff 100644 --- a/src/dotty/tools/dotc/transform/ExpandPrivate.scala +++ b/src/dotty/tools/dotc/transform/ExpandPrivate.scala @@ -17,10 +17,14 @@ import Decorators._ import ast.Trees._ import TreeTransforms._ import java.io.File.separatorChar +import ValueClasses._ /** Make private term members that are accessed from another class * non-private by resetting the Private flag and expanding their name. * + * Make private accessor in value class not-private. Ihis is necessary to unbox + * the value class when accessing it from separate compilation units + * * Also, make non-private any private parameter forwarders that forward to an inherited * public or protected parameter accessor with the same name as the forwarder. * 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 } } + private def isVCPrivateParamAccessor(d: SymDenotation)(implicit ctx: Context) = + d.isTerm && d.is(PrivateParamAccessor) && isDerivedValueClass(d.owner) + /** Make private terms accessed from different classes non-private. * Note: this happens also for accesses between class and linked module class. * If we change the scheme at one point to make static module class computations * static members of the companion class, we should tighten the condition below. */ private def ensurePrivateAccessible(d: SymDenotation)(implicit ctx: Context) = - if (d.is(PrivateTerm) && d.owner != ctx.owner.enclosingClass) { + if (isVCPrivateParamAccessor(d)) + d.ensureNotPrivate.installAfter(thisTransform) + else if (d.is(PrivateTerm) && d.owner != ctx.owner.enclosingClass) { // Paths `p1` and `p2` are similar if they have a common suffix that follows // possibly different directory paths. That is, their common suffix extends // 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 if sym.is(PrivateParamAccessor) && sel.symbol.is(ParamAccessor) && sym.name == sel.symbol.name => sym.ensureNotPrivate.installAfter(thisTransform) case _ => + if (isVCPrivateParamAccessor(sym)) + sym.ensureNotPrivate.installAfter(thisTransform) } tree } |