@@ -24,7 +24,8 @@ class MoveStatics extends MiniPhase with SymTransformer {
24
24
override def phaseName : String = MoveStatics .name
25
25
26
26
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 )) {
28
29
sym.owner.asClass.delete(sym.symbol)
29
30
sym.owner.companionClass.asClass.enter(sym.symbol)
30
31
val flags = if (sym.is(Flags .Method )) sym.flags else sym.flags | Flags .Mutable
@@ -60,9 +61,10 @@ class MoveStatics extends MiniPhase with SymTransformer {
60
61
def move (module : TypeDef , companion : TypeDef ): List [Tree ] = {
61
62
assert(companion ne module)
62
63
if (! module.symbol.is(Flags .Module )) move(companion, module)
64
+ else if (companion != null && companion.symbol.is(Flags .Trait )) List (module, companion)
63
65
else {
64
66
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 ) ++
66
68
module.rhs.asInstanceOf [Template ].body
67
69
val (newModuleBody, newCompanionBody) = allMembers.partition(x => {assert(x.symbol.exists); x.symbol.owner == module.symbol})
68
70
Trees .flatten(rebuild(companion, newCompanionBody) :: rebuild(module, newModuleBody) :: Nil )
0 commit comments