Skip to content

Commit 2811429

Browse files
committed
Make module classes in traits non-private in Mixin.
They will be instantiated in classes that mix in their owner trait, so they must be visible there.
1 parent 9fef766 commit 2811429

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

compiler/src/dotty/tools/dotc/transform/Mixin.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ class Mixin extends MiniPhase with SymTransformer { thisPhase =>
134134
else sym.copySymDenotation(initFlags = sym.flags &~ ParamAccessor | Deferred)
135135
sym1.ensureNotPrivate
136136
}
137+
else if sym.isAllOf(ModuleClass | Private) && sym.owner.is(Trait) then
138+
// modules in trait will be instantiated in the classes mixing in the trait; they must be made non-private
139+
// do not use ensureNotPrivate because the `name` must not be expanded in this case
140+
sym.copySymDenotation(initFlags = sym.flags &~ Private)
137141
else if (sym.isConstructor && sym.owner.is(Trait))
138142
sym.copySymDenotation(
139143
name = nme.TRAIT_CONSTRUCTOR,

0 commit comments

Comments
 (0)