File tree 2 files changed +11
-2
lines changed
compiler/src/dotty/tools/dotc/transform
2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,9 @@ class CapturedVars extends MiniPhase with IdentityDenotTransformer { thisPhase =
23
23
/** the following two members override abstract members in Transform */
24
24
val phaseName : String = " capturedVars"
25
25
26
+ override def runsAfterGroupsOf : Set [String ] = Set (LiftTry .name)
27
+ // lifting tries changes what variables are considered to be captured
28
+
26
29
private [this ] var Captured : Store .Location [collection.Set [Symbol ]] = _
27
30
private def captured (implicit ctx : Context ) = ctx.store(Captured )
28
31
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ import util.Store
30
30
class LiftTry extends MiniPhase with IdentityDenotTransformer { thisPhase =>
31
31
import ast .tpd ._
32
32
33
- val phaseName : String = " liftTry "
33
+ val phaseName : String = LiftTry .name
34
34
35
35
private var NeedLift : Store .Location [Boolean ] = _
36
36
private def needLift (implicit ctx : Context ): Boolean = ctx.store(NeedLift )
@@ -48,7 +48,11 @@ class LiftTry extends MiniPhase with IdentityDenotTransformer { thisPhase =>
48
48
if ! tree.symbol.exists
49
49
|| tree.symbol.isSelfSym
50
50
|| tree.symbol.owner == ctx.owner.enclosingMethod
51
- && ! tree.symbol.is(Lazy ) // lazy vals compile to defs, so there will be a new enclosing method
51
+ && ! tree.symbol.is(Lazy )
52
+ // The current implementation wraps initializers of lazy vals in
53
+ // calls to an initialize method, which means that a `try` in the
54
+ // initializer needs to be lifted. Note that the new scheme proposed
55
+ // in #6979 would avoid this.
52
56
then ctx
53
57
else liftingCtx(true )
54
58
@@ -74,3 +78,5 @@ class LiftTry extends MiniPhase with IdentityDenotTransformer { thisPhase =>
74
78
}
75
79
else tree
76
80
}
81
+ object LiftTry with
82
+ val name = " liftTry"
You can’t perform that action at this time.
0 commit comments