@@ -66,7 +66,7 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
66
66
/** A map from local methods and classes to the owners to which they will be lifted as members.
67
67
* For methods and classes that do not have any dependencies this will be the enclosing package.
68
68
* symbols with packages as lifted owners will subsequently represented as static
69
- * members of their toplevel class.
69
+ * members of their toplevel class, unless their enclosing class was already static .
70
70
*/
71
71
private val liftedOwner = new HashMap [Symbol , Symbol ]
72
72
@@ -288,7 +288,17 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
288
288
private def liftLocals ()(implicit ctx : Context ): Unit = {
289
289
for ((local, lOwner) <- liftedOwner) {
290
290
val (newOwner, maybeStatic) =
291
- if (lOwner is Package ) (local.topLevelClass, JavaStatic )
291
+ if (lOwner is Package ) {
292
+ val encClass = local.enclosingClass
293
+ val topClass = local.topLevelClass
294
+ // member of a static object
295
+ if (encClass.isStatic && encClass.isProperlyContainedIn(topClass)) {
296
+ // though the second condition seems weird, it's not true for symbols which are defined in some
297
+ // weird combinations of super calls.
298
+ (encClass, EmptyFlags )
299
+ } else
300
+ (topClass, JavaStatic )
301
+ }
292
302
else (lOwner, EmptyFlags )
293
303
local.copySymDenotation(
294
304
owner = newOwner,
0 commit comments