Skip to content

Commit 49ace48

Browse files
committed
MoveStatics: fix a bug.
Nicely spotted by Ycheck.
1 parent 5f73175 commit 49ace48

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/dotty/tools/dotc/transform/MoveStatics.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class MoveStatics extends MiniPhaseTransform with SymTransformer { thisTransform
3939
if (!module.symbol.is(Flags.Module)) move(companion, module)
4040
else {
4141
val allMembers =
42-
if(companion ne null) {companion.rhs.asInstanceOf[Template].body} else Nil ++
42+
(if(companion ne null) {companion.rhs.asInstanceOf[Template].body} else Nil) ++
4343
module.rhs.asInstanceOf[Template].body
4444
val (newModuleBody, newCompanionBody) = allMembers.partition(x => {assert(x.symbol.exists); x.symbol.owner == module.symbol})
4545
def rebuild(orig: TypeDef, newBody: List[Tree]): Tree = {
@@ -48,6 +48,7 @@ class MoveStatics extends MiniPhaseTransform with SymTransformer { thisTransform
4848
val staticFields = newBody.filter(x => x.isInstanceOf[ValDef] && x.symbol.hasAnnotation(defn.ScalaStaticAnnot)).asInstanceOf[List[ValDef]]
4949
val newBodyWithStaticConstr =
5050
if (staticFields.nonEmpty) {
51+
/* do NOT put Flags.JavaStatic here. It breaks .enclosingClass */
5152
val staticCostructor = ctx.newSymbol(orig.symbol, Names.STATIC_CONSTRUCTOR, Flags.Synthetic | Flags.Method, MethodType(Nil, defn.UnitType))
5253
staticCostructor.addAnnotation(Annotation(defn.ScalaStaticAnnot))
5354
staticCostructor.entered

0 commit comments

Comments
 (0)