diff options
author | Martin Odersky <odersky@gmail.com> | 2016-11-19 17:51:08 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-11-19 17:51:08 +0100 |
commit | 8932d98c4dcb6eb840cf640bc636982236613a16 (patch) | |
tree | 71540bf8bad2dfec17b984515c6fb31861df5b50 /src | |
parent | ca8def4b01369ffbb367b9bb6531dfc1ae4e7936 (diff) | |
download | dotty-8932d98c4dcb6eb840cf640bc636982236613a16.tar.gz dotty-8932d98c4dcb6eb840cf640bc636982236613a16.tar.bz2 dotty-8932d98c4dcb6eb840cf640bc636982236613a16.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/Compiler.scala | 4 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/FrontEnd.scala | 3 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/Compiler.scala b/src/dotty/tools/dotc/Compiler.scala index 178cba7c4..4bc5263e9 100644 --- a/src/dotty/tools/dotc/Compiler.scala +++ b/src/dotty/tools/dotc/Compiler.scala @@ -11,6 +11,7 @@ import typer.{FrontEnd, Typer, ImportInfo, RefChecks} import reporting.{Reporter, ConsoleReporter} import Phases.Phase import transform._ +import util.FreshNameCreator import transform.TreeTransforms.{TreeTransform, TreeTransformer} import core.DenotTransformers.DenotTransformer import core.Denotations.SingleDenotation @@ -140,7 +141,8 @@ class Compiler { .setTyper(new Typer) .setMode(Mode.ImplicitsEnabled) .setTyperState(new MutableTyperState(ctx.typerState, ctx.typerState.reporter, isCommittable = true)) - ctx.initialize()(start) // re-initialize the base context with start + .setFreshNames(new FreshNameCreator.Default) + ctx.initialize()(start) // re-initialize the base context with start def addImport(ctx: Context, refFn: () => TermRef) = ctx.fresh.setImportInfo(ImportInfo.rootImport(refFn)(ctx)) (start.setRunInfo(new RunInfo(start)) /: defn.RootImportFns)(addImport) diff --git a/src/dotty/tools/dotc/typer/FrontEnd.scala b/src/dotty/tools/dotc/typer/FrontEnd.scala index 4f8bc55d8..c444631ae 100644 --- a/src/dotty/tools/dotc/typer/FrontEnd.scala +++ b/src/dotty/tools/dotc/typer/FrontEnd.scala @@ -12,7 +12,6 @@ import config.Printers.{typr, default} import util.Stats._ import scala.util.control.NonFatal import ast.Trees._ -import util.FreshNameCreator class FrontEnd extends Phase { @@ -66,7 +65,7 @@ class FrontEnd extends Phase { override def runOn(units: List[CompilationUnit])(implicit ctx: Context): List[CompilationUnit] = { val unitContexts = for (unit <- units) yield { ctx.inform(s"compiling ${unit.source}") - ctx.fresh.setCompilationUnit(unit).setFreshNames(new FreshNameCreator.Default) + ctx.fresh.setCompilationUnit(unit) } unitContexts foreach (parse(_)) record("parsedTrees", ast.Trees.ntrees) |