Skip to content

Commit 368366a

Browse files
authored
Merge pull request #1933 from dotty-staging/merge-companion
Weaken assumption in mergeCompanionDefs
2 parents 8408ac9 + e53ace1 commit 368366a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,8 @@ class Namer { typer: Typer =>
491491
if (cdef.isClassDef) {
492492
classDef(name) = cdef
493493
cdef.attachmentOrElse(ExpandedTree, cdef) match {
494-
case Thicket(cls :: mval :: (mcls @ TypeDef(_, _: Template)) :: crest) =>
494+
case Thicket(cls :: mval :: (mcls @ TypeDef(mname, _: Template)) :: crest)
495+
if name.moduleClassName == mname =>
495496
moduleDef(name) = mcls
496497
case _ =>
497498
}
@@ -505,7 +506,8 @@ class Namer { typer: Typer =>
505506
classDef get name.toTypeName match {
506507
case Some(cdef) =>
507508
cdef.attachmentOrElse(ExpandedTree, cdef) match {
508-
case Thicket(cls :: mval :: TypeDef(_, compimpl: Template) :: crest) =>
509+
case Thicket(cls :: mval :: TypeDef(mname, compimpl: Template) :: crest)
510+
if name.moduleClassName == mname =>
509511
val mcls1 = cpy.TypeDef(mcls)(
510512
rhs = cpy.Template(impl)(body = compimpl.body ++ impl.body))
511513
mdef.putAttachment(ExpandedTree, Thicket(vdef :: mcls1 :: rest))

0 commit comments

Comments
 (0)