diff options
author | Martin Odersky <odersky@gmail.com> | 2014-03-29 15:05:07 +0100 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-03-31 14:52:08 +0200 |
commit | fc4648d33a051ff5d220c2fea097fc99b5883ecc (patch) | |
tree | 90306579eb4bcb1862e7e642ce68ca40471b00b8 /src/dotty/tools/dotc/Run.scala | |
parent | 26b8ec48adec709cf2b07b470ada774c708e96a4 (diff) | |
download | dotty-fc4648d33a051ff5d220c2fea097fc99b5883ecc.tar.gz dotty-fc4648d33a051ff5d220c2fea097fc99b5883ecc.tar.bz2 dotty-fc4648d33a051ff5d220c2fea097fc99b5883ecc.zip |
Add -Ycheck capability
Right now uses a super-rudementary tree checker: we only check that every tree
has a type.
Diffstat (limited to 'src/dotty/tools/dotc/Run.scala')
-rw-r--r-- | src/dotty/tools/dotc/Run.scala | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/Run.scala b/src/dotty/tools/dotc/Run.scala index 3f15bd4c3..264373baf 100644 --- a/src/dotty/tools/dotc/Run.scala +++ b/src/dotty/tools/dotc/Run.scala @@ -6,6 +6,7 @@ import Contexts._, Periods._, Symbols._, Phases._, Decorators._ import io.PlainFile import util.{SourceFile, NoSource, Stats, SimpleMap} import reporting.Reporter +import transform.TreeChecker import java.io.{BufferedWriter, OutputStreamWriter} import scala.reflect.io.VirtualFile @@ -39,18 +40,19 @@ class Run(comp: Compiler)(implicit ctx: Context) { for (phase <- phasesToRun) { if (!ctx.reporter.hasErrors) { phase.runOn(units) - if (ctx.settings.Xprint.value.containsPhase(phase)) - for (unit <- units) - printTree(ctx.fresh.setPhase(phase).setCompilationUnit(unit)) + def foreachUnit(op: Context => Unit)(implicit ctx: Context): Unit = + for (unit <- units) op(ctx.fresh.setPhase(phase.next).setCompilationUnit(unit)) + if (ctx.settings.Xprint.value.containsPhase(phase)) foreachUnit(printTree) + if (ctx.settings.Ycheck.value.containsPhase(phase)) foreachUnit(TreeChecker.check) } } } } - private def printTree(implicit ctx: Context) = { + private def printTree(ctx: Context) = { val unit = ctx.compilationUnit println(s"result of $unit after ${ctx.phase}:") - println(unit.tpdTree.show) + println(unit.tpdTree.show(ctx)) } def compile(sourceCode: String): Unit = { |