File tree 3 files changed +12
-19
lines changed
compiler/src/dotty/tools/dotc 3 files changed +12
-19
lines changed Original file line number Diff line number Diff line change @@ -81,8 +81,6 @@ class CompilationUnit protected (val source: SourceFile) {
81
81
82
82
private var myAssignmentSpans : Map [Int , List [Span ]] = null
83
83
84
- var myContext : Context = null
85
-
86
84
/** A map from (name-) offsets of all local variables in this compilation unit
87
85
* that can be tracked for being not null to the list of spans of assignments
88
86
* to these variables.
Original file line number Diff line number Diff line change @@ -49,13 +49,11 @@ class Parser extends Phase {
49
49
override def runOn (units : List [CompilationUnit ])(using Context ): List [CompilationUnit ] = {
50
50
val unitContexts =
51
51
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
+
56
55
unitContexts.foreach(parse(using _))
57
56
record(" parsedTrees" , ast.Trees .ntrees)
58
-
59
57
60
58
unitContexts.map(_.compilationUnit)
61
59
}
Original file line number Diff line number Diff line change @@ -74,14 +74,16 @@ class TyperPhase extends Phase {
74
74
unit.isJava || unit.suspended
75
75
76
76
override def runOn (units : List [CompilationUnit ])(using Context ): List [CompilationUnit ] =
77
- val unitContextsForSyms =
77
+ val unitContexts =
78
78
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
85
87
while remaining.nonEmpty do
86
88
enterSyms(using remaining.head)
87
89
remaining = remaining.tail
@@ -95,11 +97,6 @@ class TyperPhase extends Phase {
95
97
case _ =>
96
98
}
97
99
98
- val unitContexts = unitContextsForSyms
99
- // for unit <- units yield
100
- // unit.myContext.fresh.setPhase(this.start).setCompilationUnit(unit).withRootImports
101
-
102
-
103
100
unitContexts.foreach(typeCheck(using _))
104
101
record(" total trees after typer" , ast.Trees .ntrees)
105
102
unitContexts.foreach(javaCheck(using _)) // after typechecking to avoid cycles
You can’t perform that action at this time.
0 commit comments