diff options
author | odersky <odersky@gmail.com> | 2015-11-05 12:25:47 +0100 |
---|---|---|
committer | odersky <odersky@gmail.com> | 2015-11-05 12:25:47 +0100 |
commit | c16c7f6009c5c7255cf3768585c1115a82b5a38c (patch) | |
tree | 972980b591e089463e8ac1b1ef720305137847da /src/dotty/tools | |
parent | 0f04188f0b8fa94663741234bbd8cb163b5f42b1 (diff) | |
parent | 970a2bdc6c3ea7740e86217e1f30adb998457db9 (diff) | |
download | dotty-c16c7f6009c5c7255cf3768585c1115a82b5a38c.tar.gz dotty-c16c7f6009c5c7255cf3768585c1115a82b5a38c.tar.bz2 dotty-c16c7f6009c5c7255cf3768585c1115a82b5a38c.zip |
Merge pull request #889 from dotty-staging/fix-#877
Fix #877
Diffstat (limited to 'src/dotty/tools')
-rw-r--r-- | src/dotty/tools/dotc/Compiler.scala | 9 | ||||
-rw-r--r-- | src/dotty/tools/dotc/ast/Desugar.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Contexts.scala | 16 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/FrontEnd.scala | 4 |
4 files changed, 18 insertions, 13 deletions
diff --git a/src/dotty/tools/dotc/Compiler.scala b/src/dotty/tools/dotc/Compiler.scala index a36743b59..bf3dbb232 100644 --- a/src/dotty/tools/dotc/Compiler.scala +++ b/src/dotty/tools/dotc/Compiler.scala @@ -9,11 +9,10 @@ import Scopes._ import typer.{FrontEnd, Typer, Mode, ImportInfo, RefChecks} import reporting.{Reporter, ConsoleReporter} import Phases.Phase -import dotty.tools.dotc.transform._ -import dotty.tools.dotc.transform.TreeTransforms.{TreeTransform, TreeTransformer} -import dotty.tools.dotc.core.DenotTransformers.DenotTransformer -import dotty.tools.dotc.core.Denotations.SingleDenotation - +import transform._ +import transform.TreeTransforms.{TreeTransform, TreeTransformer} +import core.DenotTransformers.DenotTransformer +import core.Denotations.SingleDenotation import dotty.tools.backend.jvm.{LabelDefs, GenBCode} diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala index 0cd5eae67..33205dfd4 100644 --- a/src/dotty/tools/dotc/ast/Desugar.scala +++ b/src/dotty/tools/dotc/ast/Desugar.scala @@ -132,7 +132,7 @@ object desugar { case tparam @ TypeDef(_, ContextBounds(tbounds, cxbounds)) => for (cxbound <- cxbounds) { val paramFlags: FlagSet = if (isPrimaryConstructor) PrivateLocalParamAccessor else Param - val epname = (nme.EVIDENCE_PARAM_PREFIX.toString + epbuf.length).toTermName + val epname = ctx.freshName(nme.EVIDENCE_PARAM_PREFIX).toTermName epbuf += ValDef(epname, cxbound, EmptyTree).withFlags(paramFlags | Implicit) } cpy.TypeDef(tparam)(rhs = tbounds) diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala index d5fdba1af..522240b0f 100644 --- a/src/dotty/tools/dotc/core/Contexts.scala +++ b/src/dotty/tools/dotc/core/Contexts.scala @@ -153,6 +153,14 @@ object Contexts { protected def gadt_=(gadt: GADTMap) = _gadt = gadt def gadt: GADTMap = _gadt + /**The current fresh name creator */ + private[this] var _freshNames: FreshNameCreator = _ + protected def freshNames_=(freshNames: FreshNameCreator) = _freshNames = freshNames + def freshNames: FreshNameCreator = _freshNames + + def freshName(prefix: String = ""): String = freshNames.newName(prefix) + def freshName(prefix: Name): String = freshName(prefix.toString) + /** A map in which more contextual properties can be stored */ private var _moreProperties: Map[String, Any] = _ protected def moreProperties_=(moreProperties: Map[String, Any]) = _moreProperties = moreProperties @@ -423,6 +431,7 @@ object Contexts { def setDiagnostics(diagnostics: Option[StringBuilder]): this.type = { this.diagnostics = diagnostics; this } def setTypeComparerFn(tcfn: Context => TypeComparer): this.type = { this.typeComparer = tcfn(this); this } def setSearchHistory(searchHistory: SearchHistory): this.type = { this.searchHistory = searchHistory; this } + def setFreshNames(freshNames: FreshNameCreator): this.type = { this.freshNames = freshNames; this } def setMoreProperties(moreProperties: Map[String, Any]): this.type = { this.moreProperties = moreProperties; this } def setProperty(prop: (String, Any)): this.type = setMoreProperties(moreProperties + prop) @@ -468,6 +477,7 @@ object Contexts { typeAssigner = TypeAssigner runInfo = new RunInfo(this) diagnostics = None + freshNames = new FreshNameCreator.Default moreProperties = Map.empty typeComparer = new TypeComparer(this) searchHistory = new SearchHistory(0, Map()) @@ -498,12 +508,6 @@ object Contexts { /** The platform */ val platform: Platform = new JavaPlatform - /** The standard fresh name creator */ - val freshNames = new FreshNameCreator.Default - - def freshName(prefix: String = ""): String = freshNames.newName(prefix) - def freshName(prefix: Name): String = freshName(prefix.toString) - /** The loader that loads the members of _root_ */ def rootLoader(root: TermSymbol)(implicit ctx: Context): SymbolLoader = platform.rootLoader(root) diff --git a/src/dotty/tools/dotc/typer/FrontEnd.scala b/src/dotty/tools/dotc/typer/FrontEnd.scala index 26ee81796..e8a0adf19 100644 --- a/src/dotty/tools/dotc/typer/FrontEnd.scala +++ b/src/dotty/tools/dotc/typer/FrontEnd.scala @@ -9,6 +9,7 @@ import parsing.Parsers.Parser import config.Printers._ import util.Stats._ import scala.util.control.NonFatal +import util.FreshNameCreator class FrontEnd extends Phase { @@ -47,7 +48,8 @@ class FrontEnd extends Phase { } override def runOn(units: List[CompilationUnit])(implicit ctx: Context): List[CompilationUnit] = { - val unitContexts = units map (unit => ctx.fresh.setCompilationUnit(unit)) + val unitContexts = for (unit <- units) yield + ctx.fresh.setCompilationUnit(unit).setFreshNames(new FreshNameCreator.Default) unitContexts foreach (parse(_)) record("parsedTrees", ast.Trees.ntrees) unitContexts foreach (enterSyms(_)) |