@@ -8,6 +8,7 @@ import Symbols._, StdNames._, Trees._
88import Decorators ._ , transform .SymUtils ._
99import NameKinds .{UniqueName , EvidenceParamName , DefaultGetterName }
1010import typer .FrontEnd
11+ import util .Property
1112import collection .mutable .ListBuffer
1213import reporting .diagnostic .messages ._
1314import reporting .trace
@@ -18,6 +19,11 @@ object desugar {
1819 import untpd ._
1920 import DesugarEnums ._
2021
22+ /** If a Select node carries this attachment, suppress the check
23+ * that its type refers to an acessible symbol.
24+ */
25+ val SuppressAccessCheck = new Property .Key [Unit ]
26+
2127 /** Info of a variable in a pattern: The named tree and its type */
2228 private type VarInfo = (NameTree , Tree )
2329
@@ -727,9 +733,11 @@ object desugar {
727733 fwd
728734 }
729735 val moduleName = tdef.name.toTermName
730- val aliasType = cpy.TypeDef (tdef)(
731- rhs = completeForwarder(Select (Ident (moduleName), tdef.name)))
732- val localType = tdef.withFlags(Synthetic | Opaque )
736+ val localRef = Select (Ident (moduleName), tdef.name)
737+ localRef.pushAttachment(SuppressAccessCheck , ())
738+ val aliasType = cpy.TypeDef (tdef)(rhs = completeForwarder(localRef))
739+ val localType = tdef.withMods(Modifiers (Synthetic | Opaque ).withPrivateWithin(tdef.name))
740+
733741 val companions = moduleDef(ModuleDef (
734742 moduleName, Template (emptyConstructor, Nil , EmptyValDef , localType :: Nil ))
735743 .withFlags(Synthetic | Opaque ))
0 commit comments