@@ -24,7 +24,8 @@ class MoveStatics extends MiniPhase with SymTransformer {
2424 override def phaseName : String = MoveStatics .name
2525
2626 def transformSym (sym : SymDenotation )(implicit ctx : Context ): SymDenotation = {
27- if (sym.hasAnnotation(defn.ScalaStaticAnnot ) && sym.owner.is(Flags .Module ) && sym.owner.companionClass.exists) {
27+ if (sym.hasAnnotation(defn.ScalaStaticAnnot ) && sym.owner.is(Flags .Module ) &&
28+ sym.owner.companionClass.exists && ! sym.owner.companionClass.is(Flags .Trait )) {
2829 sym.owner.asClass.delete(sym.symbol)
2930 sym.owner.companionClass.asClass.enter(sym.symbol)
3031 val flags = if (sym.is(Flags .Method )) sym.flags else sym.flags | Flags .Mutable
@@ -60,9 +61,10 @@ class MoveStatics extends MiniPhase with SymTransformer {
6061 def move (module : TypeDef , companion : TypeDef ): List [Tree ] = {
6162 assert(companion ne module)
6263 if (! module.symbol.is(Flags .Module )) move(companion, module)
64+ else if (companion != null && companion.symbol.is(Flags .Trait )) List (module, companion)
6365 else {
6466 val allMembers =
65- (if (companion ne null ) {companion.rhs.asInstanceOf [Template ].body} else Nil ) ++
67+ (if (companion != null ) {companion.rhs.asInstanceOf [Template ].body} else Nil ) ++
6668 module.rhs.asInstanceOf [Template ].body
6769 val (newModuleBody, newCompanionBody) = allMembers.partition(x => {assert(x.symbol.exists); x.symbol.owner == module.symbol})
6870 Trees .flatten(rebuild(companion, newCompanionBody) :: rebuild(module, newModuleBody) :: Nil )
0 commit comments