File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -934,6 +934,9 @@ object SymDenotations {
934934 ( ! this .is(Local )
935935 || isAccessPrivilegedThisType(pre)
936936 || canBeLocal(name, flags)
937+ && {
938+ ! symbol.defTree.hasAttachment(typer.Typer .OriginallyPrivateLocal )
939+ }
937940 && {
938941 resetFlag(Local )
939942 true
@@ -2658,8 +2661,6 @@ object SymDenotations {
26582661 * This holds for all symbols except
26592662 * - constructors, since they can never be referred to as members of their
26602663 * own, fully elaborated `this`.
2661- * - parameters and parameter accessors, since their Local status is already
2662- * determined by whether they have a `val` or `var` or not.
26632664 */
26642665 def canBeLocal (name : Name , flags : FlagSet )(using Context ) =
26652666 ! name.isConstructorName
Original file line number Diff line number Diff line change @@ -87,6 +87,10 @@ object Typer {
8787 /** Tree adaptation lost fidelity; this attachment preserves the original tree. */
8888 val AdaptedTree = new Property .StickyKey [tpd.Tree ]
8989
90+ /** An attachment on a tree that was originally private local
91+ */
92+ val OriginallyPrivateLocal = new Property .Key [Unit ]
93+
9094 /** An attachment on a Select node with an `apply` field indicating that the `apply`
9195 * was inserted by the Typer.
9296 */
@@ -3039,6 +3043,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
30393043 report.error(em " Cannot return repeated parameter type ${sym.info.finalResultType}" , sym.srcPos)
30403044 if ! sym.is(Module ) && ! sym.isConstructor && sym.info.finalResultType.isErasedClass then
30413045 sym.setFlag(Erased )
3046+ // This is probably too late. Do this in Namer?
3047+ if mdef.isInstanceOf [ValDef ] && sym.isAllOf(PrivateLocal ) then
3048+ mdef.putAttachment(OriginallyPrivateLocal , ())
30423049 mdef.ensureHasSym(sym)
30433050 mdef.setDefTree
30443051
Original file line number Diff line number Diff line change 1+ sealed abstract class Tree [+ A ](
2+ final val key : A
3+ )
4+ final class RedTree [+ A ](key : A ) extends Tree [A ](key)
5+ final class BlackTree [+ A ](key : A ) extends Tree [A ](key)
6+ object RedTree {
7+ def unapply [A ](t : RedTree [A ]) = Some ((t.key))
8+ }
9+ object BlackTree {
10+ def unapply [A ](t : BlackTree [A ]) = Some ((t.key))
11+ }
You can’t perform that action at this time.
0 commit comments