Skip to content

Commit 8932d98

Browse files
committed
Recreate FreshNameCreator for each run.
Previously only the FrontEnd got a fresh FreshNameCreator for each run, the other phases used a global one instead. This means that compiling the same file several times would create different synthetic names and classes on each run.
1 parent ca8def4 commit 8932d98

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/dotty/tools/dotc/Compiler.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import typer.{FrontEnd, Typer, ImportInfo, RefChecks}
1111
import reporting.{Reporter, ConsoleReporter}
1212
import Phases.Phase
1313
import transform._
14+
import util.FreshNameCreator
1415
import transform.TreeTransforms.{TreeTransform, TreeTransformer}
1516
import core.DenotTransformers.DenotTransformer
1617
import core.Denotations.SingleDenotation
@@ -140,7 +141,8 @@ class Compiler {
140141
.setTyper(new Typer)
141142
.setMode(Mode.ImplicitsEnabled)
142143
.setTyperState(new MutableTyperState(ctx.typerState, ctx.typerState.reporter, isCommittable = true))
143-
ctx.initialize()(start) // re-initialize the base context with start
144+
.setFreshNames(new FreshNameCreator.Default)
145+
ctx.initialize()(start) // re-initialize the base context with start
144146
def addImport(ctx: Context, refFn: () => TermRef) =
145147
ctx.fresh.setImportInfo(ImportInfo.rootImport(refFn)(ctx))
146148
(start.setRunInfo(new RunInfo(start)) /: defn.RootImportFns)(addImport)

src/dotty/tools/dotc/typer/FrontEnd.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import config.Printers.{typr, default}
1212
import util.Stats._
1313
import scala.util.control.NonFatal
1414
import ast.Trees._
15-
import util.FreshNameCreator
1615

1716
class FrontEnd extends Phase {
1817

@@ -66,7 +65,7 @@ class FrontEnd extends Phase {
6665
override def runOn(units: List[CompilationUnit])(implicit ctx: Context): List[CompilationUnit] = {
6766
val unitContexts = for (unit <- units) yield {
6867
ctx.inform(s"compiling ${unit.source}")
69-
ctx.fresh.setCompilationUnit(unit).setFreshNames(new FreshNameCreator.Default)
68+
ctx.fresh.setCompilationUnit(unit)
7069
}
7170
unitContexts foreach (parse(_))
7271
record("parsedTrees", ast.Trees.ntrees)

0 commit comments

Comments
 (0)