@@ -499,23 +499,28 @@ class Namer { typer: Typer =>
499
499
}
500
500
for (mdef @ ModuleDef (name, _) <- stats if ! mdef.mods.is(Flags .Package )) {
501
501
val typName = name.toTypeName
502
- // Expansion of object is a flattened thicket with the first two elements being:
503
- // module val :: module class :: rest
504
- val Thicket (vdef :: (mcls @ TypeDef (_, impl : Template )) :: rest) = expanded(mdef)
505
- moduleDef(typName) = mcls
506
- classDef get name.toTypeName match {
507
- case Some (cdef) =>
508
- cdef.attachmentOrElse(ExpandedTree , cdef) match {
509
- case Thicket (cls :: mval :: TypeDef (mname, compimpl : Template ) :: crest)
510
- if name.moduleClassName == mname =>
511
- val mcls1 = cpy.TypeDef (mcls)(
512
- rhs = cpy.Template (impl)(body = compimpl.body ++ impl.body))
513
- mdef.putAttachment(ExpandedTree , Thicket (vdef :: mcls1 :: rest))
514
- moduleDef(typName) = mcls1
515
- cdef.putAttachment(ExpandedTree , Thicket (cls :: crest))
516
- case _ =>
502
+ expanded(mdef) match {
503
+ // Expansion of non-enum object is a flattened thicket with the first two elements being:
504
+ // module val :: module class :: rest
505
+ case Thicket (vdef :: (mcls @ TypeDef (_, impl : Template )) :: rest) =>
506
+ moduleDef(typName) = mcls
507
+ classDef get name.toTypeName match {
508
+ case Some (cdef) =>
509
+ cdef.attachmentOrElse(ExpandedTree , cdef) match {
510
+ case Thicket (cls :: mval :: TypeDef (mname, compimpl : Template ) :: crest)
511
+ if name.moduleClassName == mname =>
512
+ val mcls1 = cpy.TypeDef (mcls)(
513
+ rhs = cpy.Template (impl)(body = compimpl.body ++ impl.body))
514
+ mdef.putAttachment(ExpandedTree , Thicket (vdef :: mcls1 :: rest))
515
+ moduleDef(typName) = mcls1
516
+ cdef.putAttachment(ExpandedTree , Thicket (cls :: crest))
517
+ case _ =>
518
+ }
519
+ case none =>
517
520
}
518
- case none =>
521
+ case _ =>
522
+ // An enum module is expanded to a val. This val is not merged
523
+ // with a companion module.
519
524
}
520
525
}
521
526
}
0 commit comments