@@ -9,10 +9,12 @@ import util.{FreshNameCreator, SourceFile, NoSource}
9
9
import util .Spans .Span
10
10
import ast .{tpd , untpd }
11
11
import tpd .{Tree , TreeTraverser }
12
+ import ast .Trees .Import
12
13
import typer .Nullables
13
14
import transform .SymUtils ._
14
15
import core .Decorators ._
15
16
import config .SourceVersion
17
+ import StdNames .nme
16
18
import scala .annotation .internal .sharable
17
19
18
20
class CompilationUnit protected (val source : SourceFile ) {
@@ -51,6 +53,9 @@ class CompilationUnit protected (val source: SourceFile) {
51
53
*/
52
54
var needsStaging : Boolean = false
53
55
56
+ /** Will be set to true if the unit contains a captureChecking language import */
57
+ var needsCaptureChecking : Boolean = false
58
+
54
59
var suspended : Boolean = false
55
60
var suspendedAtInliningPhase : Boolean = false
56
61
@@ -111,6 +116,7 @@ object CompilationUnit {
111
116
force.traverse(unit1.tpdTree)
112
117
unit1.needsStaging = force.containsQuote
113
118
unit1.needsInlining = force.containsInline
119
+ unit1.needsCaptureChecking = force.containsCaptureChecking
114
120
}
115
121
unit1
116
122
}
@@ -138,11 +144,17 @@ object CompilationUnit {
138
144
private class Force extends TreeTraverser {
139
145
var containsQuote = false
140
146
var containsInline = false
147
+ var containsCaptureChecking = false
141
148
def traverse (tree : Tree )(using Context ): Unit = {
142
149
if (tree.symbol.isQuote)
143
150
containsQuote = true
144
151
if tree.symbol.is(Flags .Inline ) then
145
152
containsInline = true
153
+ tree match
154
+ case Import (qual, selectors)
155
+ if tpd.languageImport(qual).isDefined && selectors.contains(nme.captureChecking) =>
156
+ containsCaptureChecking = true
157
+ case _ =>
146
158
traverseChildren(tree)
147
159
}
148
160
}
0 commit comments