@@ -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 }
@@ -303,17 +303,30 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
303
303
.withRootImports
304
304
305
305
def process ()(using Context ) = {
306
- unit.untpdTree =
306
+
307
+ def parseSource ()(using Context ) =
307
308
if (unit.isJava) new JavaParser (unit.source).parse()
308
309
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()
310
+
311
+ def enterTrees ()(using Context ) =
312
+ ctx.typer.lateEnter(unit.untpdTree)
313
+ def typeCheckUnit ()(using Context ) =
314
+ unit.tpdTree = ctx.typer.typedExpr(unit.untpdTree)
315
+ val phase = new transform.SetRootTree ()
316
+ phase.run
317
+ if typeCheck then
318
+ val typerCtx : Context =
319
+ // typer phase allows implicits to be searched
320
+ ctx.withPhase(Phases .typerPhase)
321
+ if compiling then finalizeActions += (() => typeCheckUnit()(using typerCtx))
322
+ else typeCheckUnit()(using typerCtx)
323
+
324
+ unit.untpdTree = parseSource()
325
+ val namerCtx =
326
+ // inline body annotations are set in namer, capturing the current context
327
+ // we need to prepare the context for inlining.
328
+ if unit.isJava then ctx else PrepareInlineable .initContext(ctx)
329
+ enterTrees()(using namerCtx)
317
330
}
318
331
process()(using unitCtx)
319
332
}
0 commit comments