@@ -9,7 +9,7 @@ import Types._
99import Scopes ._
1010import Names .Name
1111import Denotations .Denotation
12- import typer .Typer
12+ import typer .{ Typer , PrepareInlineable }
1313import typer .ImportInfo ._
1414import Decorators ._
1515import io .{AbstractFile , PlainFile , VirtualFile }
@@ -303,17 +303,30 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
303303 .withRootImports
304304
305305 def process ()(using Context ) = {
306- unit.untpdTree =
306+
307+ def parseSource ()(using Context ) =
307308 if (unit.isJava) new JavaParser (unit.source).parse()
308309 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)
317330 }
318331 process()(using unitCtx)
319332 }
0 commit comments