Skip to content

Commit

Permalink
fix scala#13994: initialise inline ctx in lateEnter
Browse files Browse the repository at this point in the history
  • Loading branch information
bishabosha committed Dec 6, 2021
1 parent 097356d commit a433f47
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions compiler/src/dotty/tools/dotc/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Types._
import Scopes._
import Names.Name
import Denotations.Denotation
import typer.Typer
import typer.{Typer, PrepareInlineable}
import typer.ImportInfo._
import Decorators._
import io.{AbstractFile, PlainFile, VirtualFile}
Expand Down Expand Up @@ -303,17 +303,30 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
.withRootImports

def process()(using Context) = {
unit.untpdTree =

def parseSource()(using Context) =
if (unit.isJava) new JavaParser(unit.source).parse()
else new Parser(unit.source).parse()
ctx.typer.lateEnter(unit.untpdTree)
def processUnit() = {
unit.tpdTree = ctx.typer.typedExpr(unit.untpdTree)
val phase = new transform.SetRootTree()
phase.run
}
if (typeCheck)
if (compiling) finalizeActions += (() => processUnit()) else processUnit()

def enterTrees()(using Context) =
ctx.typer.lateEnter(unit.untpdTree)
def typeCheckUnit()(using Context) =
unit.tpdTree = ctx.typer.typedExpr(unit.untpdTree)
val phase = new transform.SetRootTree()
phase.run
if typeCheck then
val typerCtx: Context =
// typer phase allows implicits to be searched
ctx.withPhase(Phases.typerPhase)
if compiling then finalizeActions += (() => typeCheckUnit()(using typerCtx))
else typeCheckUnit()(using typerCtx)

unit.untpdTree = parseSource()
val namerCtx =
// inline body annotations are set in namer, capturing the current context
// we need to prepare the context for inlining.
if unit.isJava then ctx else PrepareInlineable.initContext(ctx)
enterTrees()(using namerCtx)
}
process()(using unitCtx)
}
Expand Down

0 comments on commit a433f47

Please sign in to comment.