diff options
-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 | ||||
-rw-r--r-- | tests/pos/i877.scala | 11 |
5 files changed, 29 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(_)) diff --git a/tests/pos/i877.scala b/tests/pos/i877.scala new file mode 100644 index 000000000..45a71ae0d --- /dev/null +++ b/tests/pos/i877.scala @@ -0,0 +1,11 @@ +class First[A] +class Second[A] + +class Foo { + def foo[A: First] = { + def bar[B: Second] = { + val fst: First[A] = implicitly[First[A]] + val snd: Second[B] = implicitly[Second[B]] + } + } +} |