Skip to content

Commit bb7d6dd

Browse files
committed
Avoid static initialization deadlock in run tests (2).
See #624 (comment) for a lengthy explanation. We now solve the problem in LambdaLift. The formerly failing tests are all reverted to theor original, failing, version.
1 parent 07ed3f1 commit bb7d6dd

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,15 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
210210
case tree: This =>
211211
narrowTo(tree.symbol.asClass)
212212
case tree: DefDef =>
213-
if (sym.owner.isTerm && !sym.is(Label)) liftedOwner(sym) = sym.topLevelClass.owner
214-
else if (sym.isPrimaryConstructor && sym.owner.owner.isTerm) symSet(called, sym) += sym.owner
213+
if (sym.owner.isTerm && !sym.is(Label))
214+
liftedOwner(sym) = sym.enclosingClass.topLevelClass
215+
// this will make methods in supercall constructors of top-level classes owned
216+
// by the enclosing package, which means they will be static.
217+
// On the other hand, all other methods will be indirectly owned by their
218+
// top-level class. This avoids possible deadlocks when a static method
219+
// has to access its enclosing object from the outside.
220+
else if (sym.isPrimaryConstructor && sym.owner.owner.isTerm)
221+
symSet(called, sym) += sym.owner
215222
case tree: TypeDef =>
216223
if (sym.owner.isTerm) liftedOwner(sym) = sym.topLevelClass.owner
217224
case tree: Template =>

0 commit comments

Comments
 (0)