@@ -249,14 +249,21 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
249
249
else if (sym is Method ) markCalled(sym, enclosure)
250
250
else if (sym.isTerm) markFree(sym, enclosure)
251
251
}
252
- if (sym.maybeOwner.isClass) narrowTo(sym.owner.asClass)
252
+ def captureImplicitThis (x : Type ): Unit = {
253
+ x match {
254
+ case tr@ TermRef (x, _) if (! tr.termSymbol.isStatic) => captureImplicitThis(x)
255
+ case x : ThisType if (! x.tref.typeSymbol.isStaticOwner) => narrowTo(x.tref.typeSymbol.asClass)
256
+ case _ =>
257
+ }
258
+ }
259
+ captureImplicitThis(tree.tpe)
253
260
case tree : Select =>
254
261
if (sym.is(Method ) && isLocal(sym)) markCalled(sym, enclosure)
255
262
case tree : This =>
256
263
narrowTo(tree.symbol.asClass)
257
264
case tree : DefDef =>
258
265
if (sym.owner.isTerm && ! sym.is(Label ))
259
- liftedOwner(sym) = sym.enclosingClass.topLevelClass
266
+ liftedOwner(sym) = sym.enclosingPackageClass
260
267
// this will make methods in supercall constructors of top-level classes owned
261
268
// by the enclosing package, which means they will be static.
262
269
// On the other hand, all other methods will be indirectly owned by their
@@ -362,8 +369,9 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
362
369
// though the second condition seems weird, it's not true for symbols which are defined in some
363
370
// weird combinations of super calls.
364
371
(encClass, EmptyFlags )
365
- } else
366
- (topClass, JavaStatic )
372
+ } else if (encClass.is(ModuleClass , butNot = Package ) && encClass.isStatic) // needed to not cause deadlocks in classloader. see t5375.scala
373
+ (encClass, EmptyFlags )
374
+ else (topClass, JavaStatic )
367
375
}
368
376
else (lOwner, EmptyFlags )
369
377
local.copySymDenotation(
0 commit comments