@@ -9,7 +9,7 @@ import Types._
9
9
import Scopes ._
10
10
import Names .Name
11
11
import Denotations .Denotation
12
- import typer .Typer
12
+ import typer .{ Typer , PrepareInlineable }
13
13
import typer .ImportInfo ._
14
14
import Decorators ._
15
15
import io .{AbstractFile , PlainFile , VirtualFile }
@@ -34,6 +34,7 @@ import java.nio.charset.StandardCharsets
34
34
35
35
import scala .collection .mutable
36
36
import scala .util .control .NonFatal
37
+ import scala .util .chaining .*
37
38
import scala .io .Codec
38
39
39
40
/** A compiler run. Exports various methods to compile source files */
@@ -303,17 +304,30 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
303
304
.withRootImports
304
305
305
306
def process ()(using Context ) = {
306
- unit.untpdTree =
307
+
308
+ def parseSource ()(using Context ) =
307
309
if (unit.isJava) new JavaParser (unit.source).parse()
308
310
else new Parser (unit.source).parse()
309
- ctx.typer.lateEnter(unit.untpdTree)
310
- def processUnit () = {
311
- unit.tpdTree = ctx.typer.typedExpr(unit.untpdTree)
312
- val phase = new transform.SetRootTree ()
313
- phase.run
314
- }
315
- if (typeCheck)
316
- if (compiling) finalizeActions += (() => processUnit()) else processUnit()
311
+
312
+ def enterTrees ()(using Context ) =
313
+ ctx.typer.lateEnter(unit.untpdTree)
314
+ def typeCheckUnit ()(using Context ) =
315
+ unit.tpdTree = ctx.typer.typedExpr(unit.untpdTree)
316
+ val phase = new transform.SetRootTree ()
317
+ phase.run
318
+ if typeCheck then
319
+ val typerCtx : Context =
320
+ // typer phase allows implicits to be searched
321
+ ctx.withPhase(Phases .typerPhase)
322
+ if compiling then finalizeActions += (() => typeCheckUnit()(using typerCtx))
323
+ else typeCheckUnit()(using typerCtx)
324
+
325
+ unit.untpdTree = parseSource()
326
+ val namerCtx =
327
+ // inline body annotations are set in namer, capturing the current context
328
+ // we need to prepare the context for inlining.
329
+ if unit.isJava then ctx else PrepareInlineable .initContext(ctx)
330
+ enterTrees()(using namerCtx)
317
331
}
318
332
process()(using unitCtx)
319
333
}
0 commit comments