Skip to content

Fix #877 #889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/dotty/tools/dotc/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 10 additions & 6 deletions src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion src/dotty/tools/dotc/typer/FrontEnd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -46,7 +47,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(_))
Expand Down
11 changes: 11 additions & 0 deletions tests/pos/i877.scala
Original file line number Diff line number Diff line change
@@ -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]]
}
}
}