@@ -606,11 +606,11 @@ class Namer { typer: Typer =>
606
606
}
607
607
}
608
608
609
- // If a top-level object has no companion class in the current run, we
610
- // enter a dummy companion class symbol (`denot.isAbsent` returns true) in
611
- // scope. This ensures that we never use a companion from a previous run
612
- // or from the classpath. See tests/pos/false-companion for an
613
- // example where this matters.
609
+ // If a top-level object or class has no companion in the current run, we
610
+ // enter a dummy companion (`denot.isAbsent` returns true) in scope. This
611
+ // ensures that we never use a companion from a previous run or from the
612
+ // classpath. See tests/pos/false-companion for an example where this
613
+ // matters.
614
614
if (ctx.owner.is(PackageClass )) {
615
615
for (cdef @ TypeDef (moduleName, _) <- moduleDef.values) {
616
616
val moduleSym = ctx.effectiveScope.lookup(moduleName.encode)
@@ -623,6 +623,17 @@ class Namer { typer: Typer =>
623
623
}
624
624
}
625
625
}
626
+ for (cdef @ TypeDef (className, _) <- classDef.values) {
627
+ val classSym = ctx.effectiveScope.lookup(className.encode)
628
+ if (classSym.isDefinedInCurrentRun) {
629
+ val moduleName = className.toTermName
630
+ val moduleSym = ctx.effectiveScope.lookup(moduleName.encode)
631
+ if (! moduleSym.isDefinedInCurrentRun) {
632
+ val absentModuleSymbol = ctx.newModuleSymbol(ctx.owner, moduleName, EmptyFlags , EmptyFlags , (_, _) => NoType )
633
+ enterSymbol(absentModuleSymbol)
634
+ }
635
+ }
636
+ }
626
637
}
627
638
}
628
639
0 commit comments