diff options
author | Martin Odersky <odersky@gmail.com> | 2014-04-19 19:48:57 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-05-08 21:48:08 +0200 |
commit | d78885ff06bea4840cdf9bee61dd3698fcff820a (patch) | |
tree | c93a65fdd1219d2dbe26a59de4873c79b808d471 /src | |
parent | 9203e01ddd141ddbb96e3064be5e894ddb666fd8 (diff) | |
download | dotty-d78885ff06bea4840cdf9bee61dd3698fcff820a.tar.gz dotty-d78885ff06bea4840cdf9bee61dd3698fcff820a.tar.bz2 dotty-d78885ff06bea4840cdf9bee61dd3698fcff820a.zip |
isAfterTyper test
Add test whether we are after typer. Use it to assert that
eta expansion and implicit search do not happen after typer.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/core/Phases.scala | 6 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/EtaExpansion.scala | 1 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Implicits.scala | 3 |
3 files changed, 8 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/Phases.scala b/src/dotty/tools/dotc/core/Phases.scala index f76b83db6..251cd3876 100644 --- a/src/dotty/tools/dotc/core/Phases.scala +++ b/src/dotty/tools/dotc/core/Phases.scala @@ -36,6 +36,8 @@ trait Phases { def atPhaseNotLaterThanTyper[T](op: Context => T): T = atPhaseNotLaterThan(base.typerPhase)(op) + + def isAfterTyper: Boolean = base.isAfterTyper(phase) } object Phases { @@ -177,9 +179,11 @@ object Phases { def refchecksPhase = refChecksCache.phase def erasurePhase = erasureCache.phase def flattenPhase = flattenCache.phase + + def isAfterTyper(phase: Phase): Boolean = phase.id > typerPhase.id } - final val typerName = "typer" + final val typerName = "frontend" final val refChecksName = "refchecks" final val erasureName = "erasure" final val flattenName = "flatten" diff --git a/src/dotty/tools/dotc/typer/EtaExpansion.scala b/src/dotty/tools/dotc/typer/EtaExpansion.scala index 099dd943a..110dc6152 100644 --- a/src/dotty/tools/dotc/typer/EtaExpansion.scala +++ b/src/dotty/tools/dotc/typer/EtaExpansion.scala @@ -116,6 +116,7 @@ object EtaExpansion { */ def etaExpand(tree: Tree, mt: MethodType, xarity: Int)(implicit ctx: Context): untpd.Tree = { import untpd._ + assert(!ctx.isAfterTyper) val defs = new mutable.ListBuffer[tpd.Tree] val lifted: Tree = TypedSplice(liftApp(defs, tree)) val paramTypes: List[Tree] = diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala index 93876651a..4767e6dd3 100644 --- a/src/dotty/tools/dotc/typer/Implicits.scala +++ b/src/dotty/tools/dotc/typer/Implicits.scala @@ -400,6 +400,7 @@ trait Implicits { self: Typer => * !!! todo: catch potential cycles */ def inferImplicit(pt: Type, argument: Tree, pos: Position)(implicit ctx: Context): SearchResult = track("inferImplicit") { + assert(!ctx.isAfterTyper) ctx.traceIndented(s"search implicit ${pt.show}, arg = ${argument.show}: ${argument.tpe.show}", implicits, show = true) { assert(!pt.isInstanceOf[ExprType]) val isearch = @@ -472,7 +473,7 @@ trait Implicits { self: Typer => shadowedImplicit(ref, methPart(shadowing).tpe) } else - SearchSuccess(generated, ref, ctx.typerState) + SearchSuccess(generated1, ref, ctx.typerState) }} /** Given a list of implicit references, produce a list of all implicit search successes, |