Skip to content

Commit e17e37c

Browse files
committed
myContext gone
1 parent a0a9524 commit e17e37c

File tree

3 files changed

+12
-19
lines changed

3 files changed

+12
-19
lines changed

compiler/src/dotty/tools/dotc/CompilationUnit.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ class CompilationUnit protected (val source: SourceFile) {
8181

8282
private var myAssignmentSpans: Map[Int, List[Span]] = null
8383

84-
var myContext: Context = null
85-
8684
/** A map from (name-) offsets of all local variables in this compilation unit
8785
* that can be tracked for being not null to the list of spans of assignments
8886
* to these variables.

compiler/src/dotty/tools/dotc/parsing/ParserPhase.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,11 @@ class Parser extends Phase {
4949
override def runOn(units: List[CompilationUnit])(using Context): List[CompilationUnit] = {
5050
val unitContexts =
5151
for unit <- units yield
52-
report.inform(s"running typer on ${unit.source}")
53-
val newCtx = ctx.fresh.setCompilationUnit(unit).withRootImports
54-
unit.myContext = newCtx
55-
newCtx
52+
report.inform(s"running parser on ${unit.source}")
53+
ctx.fresh.setCompilationUnit(unit).withRootImports
54+
5655
unitContexts.foreach(parse(using _))
5756
record("parsedTrees", ast.Trees.ntrees)
58-
5957

6058
unitContexts.map(_.compilationUnit)
6159
}

compiler/src/dotty/tools/dotc/typer/TyperPhase.scala

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,16 @@ class TyperPhase extends Phase {
7474
unit.isJava || unit.suspended
7575

7676
override def runOn(units: List[CompilationUnit])(using Context): List[CompilationUnit] =
77-
val unitContextsForSyms =
77+
val unitContexts =
7878
for unit <- units yield
79-
Option(unit.myContext).map(_.fresh.setPhase(this.start).setCompilationUnit(unit).withRootImports).getOrElse {
80-
// This happens in the REPL when parsing is done externally
81-
ctx.fresh.setCompilationUnit(unit)
82-
}
83-
84-
remaining = unitContextsForSyms
79+
val newCtx = ctx.fresh.setPhase(this.start).setCompilationUnit(unit)
80+
// TODO without this test, dotty.tools.repl.ScriptedTests fails. Not sure why.
81+
if (this.start > Periods.FirstPhaseId)
82+
newCtx.withRootImports
83+
else
84+
newCtx
85+
86+
remaining = unitContexts
8587
while remaining.nonEmpty do
8688
enterSyms(using remaining.head)
8789
remaining = remaining.tail
@@ -95,11 +97,6 @@ class TyperPhase extends Phase {
9597
case _ =>
9698
}
9799

98-
val unitContexts = unitContextsForSyms
99-
//for unit <- units yield
100-
//unit.myContext.fresh.setPhase(this.start).setCompilationUnit(unit).withRootImports
101-
102-
103100
unitContexts.foreach(typeCheck(using _))
104101
record("total trees after typer", ast.Trees.ntrees)
105102
unitContexts.foreach(javaCheck(using _)) // after typechecking to avoid cycles

0 commit comments

Comments
 (0)