@@ -746,6 +746,17 @@ trait Checking {
746746 em " Implementation restriction: ${path.tpe.classSymbol} is not a valid prefix " +
747747 " for a wildcard export, as it is a package." , path.srcPos)
748748
749+ /** Check that module `sym` does not clash with a class of the same name
750+ * that is concurrently compiled in another source file.
751+ */
752+ def checkNoModuleClash (sym : Symbol )(using Context ): Unit =
753+ if sym.effectiveOwner.is(Package )
754+ && sym.owner.info.member(sym.name.moduleClassName).symbol.isAbsent()
755+ then
756+ val conflicting = sym.owner.info.member(sym.name.toTypeName).symbol
757+ if conflicting.exists then
758+ report.error(AlreadyDefined (sym.name, sym.owner, conflicting), sym.srcPos)
759+
749760 /** Check that `tp` is a class type.
750761 * Also, if `traitReq` is true, check that `tp` is a trait.
751762 * Also, if `stablePrefixReq` is true and phase is not after RefChecks,
@@ -1266,6 +1277,7 @@ trait ReChecking extends Checking {
12661277 override def checkEnumCaseRefsLegal (cdef : TypeDef , enumCtx : Context )(using Context ): Unit = ()
12671278 override def checkAnnotApplicable (annot : Tree , sym : Symbol )(using Context ): Boolean = true
12681279 override def checkMatchable (tp : Type , pos : SrcPos , pattern : Boolean )(using Context ): Unit = ()
1280+ override def checkNoModuleClash (sym : Symbol )(using Context ) = ()
12691281}
12701282
12711283trait NoChecking extends ReChecking {
0 commit comments