Skip to content

Commit b0856fe

Browse files
committed
Fix #545: no need to make members of static classes static.
Otherwise we will need to rewrite references to `This` of class be references on ModuleVal. This is less efficient(instead of calling method statically known to be final, you have virtual call) and less jvm-friendly, as needs additional instructions to get to ModuleVal.
1 parent a52ca60 commit b0856fe

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,13 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
288288
private def liftLocals()(implicit ctx: Context): Unit = {
289289
for ((local, lOwner) <- liftedOwner) {
290290
val (newOwner, maybeStatic) =
291-
if (lOwner is Package) (local.topLevelClass, JavaStatic)
291+
if (lOwner is Package) {
292+
println(s"lifting $local encl class ${local.enclosingClass}")
293+
if (local.enclosingClass.isStatic) // member of a static object
294+
(local.enclosingClass, EmptyFlags)
295+
else
296+
(local.topLevelClass, JavaStatic)
297+
}
292298
else (lOwner, EmptyFlags)
293299
local.copySymDenotation(
294300
owner = newOwner,

0 commit comments

Comments
 (0)