aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-04-27 10:33:00 +0200
committerMartin Odersky <odersky@gmail.com>2016-04-27 14:01:41 +0200
commit5e599cc14ac0dfe9f7b7605e537808c927e7a6a3 (patch)
tree76c27f128a5aed82d52dda4ca1c5d79f6aff9a19 /src/dotty/tools/dotc
parent4d7aaf637edafa1305602fc9f63b4c2ed4288ad5 (diff)
downloaddotty-5e599cc14ac0dfe9f7b7605e537808c927e7a6a3.tar.gz
dotty-5e599cc14ac0dfe9f7b7605e537808c927e7a6a3.tar.bz2
dotty-5e599cc14ac0dfe9f7b7605e537808c927e7a6a3.zip
Rename Reporting#println -> Reporting#echo
There's a trap otherwise that, when in a class inheriting from Context (and with it Reporting) a call to println will go to this.println and therefore might not print at all, if the current context buffers messages. I lost a lot of time on this on several occasions when I scratched my head why a simple debug println would not show. Better avoid this in the future for myself and others.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/Run.scala6
-rw-r--r--src/dotty/tools/dotc/config/CompilerCommand.scala8
-rw-r--r--src/dotty/tools/dotc/core/Denotations.scala2
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala8
-rw-r--r--src/dotty/tools/dotc/reporting/Reporter.scala9
-rw-r--r--src/dotty/tools/dotc/rewrite/Rewrites.scala2
-rw-r--r--src/dotty/tools/dotc/transform/TreeChecker.scala16
-rw-r--r--src/dotty/tools/dotc/typer/FrontEnd.scala2
8 files changed, 26 insertions, 27 deletions
diff --git a/src/dotty/tools/dotc/Run.scala b/src/dotty/tools/dotc/Run.scala
index 7a0e555e4..928a59214 100644
--- a/src/dotty/tools/dotc/Run.scala
+++ b/src/dotty/tools/dotc/Run.scala
@@ -35,7 +35,7 @@ class Run(comp: Compiler)(implicit ctx: Context) {
compileSources(sources)
} catch {
case NonFatal(ex) =>
- ctx.println(i"exception occurred while compiling $units%, %")
+ ctx.echo(i"exception occurred while compiling $units%, %")
throw ex
}
@@ -74,8 +74,8 @@ class Run(comp: Compiler)(implicit ctx: Context) {
val prevPhase = ctx.phase.prev // can be a mini-phase
val squashedPhase = ctx.squashed(prevPhase)
- ctx.println(s"result of $unit after ${squashedPhase}:")
- ctx.println(unit.tpdTree.show(ctx))
+ ctx.echo(s"result of $unit after ${squashedPhase}:")
+ ctx.echo(unit.tpdTree.show(ctx))
}
def compile(sourceCode: String): Unit = {
diff --git a/src/dotty/tools/dotc/config/CompilerCommand.scala b/src/dotty/tools/dotc/config/CompilerCommand.scala
index e34ca07f9..2fe32b4d3 100644
--- a/src/dotty/tools/dotc/config/CompilerCommand.scala
+++ b/src/dotty/tools/dotc/config/CompilerCommand.scala
@@ -110,18 +110,18 @@ object CompilerCommand extends DotClass {
if (summary.errors.nonEmpty) {
summary.errors foreach (ctx.error(_))
- ctx.println(" dotc -help gives more information")
+ ctx.echo(" dotc -help gives more information")
Nil
}
else if (settings.version.value) {
- ctx.println(versionMsg)
+ ctx.echo(versionMsg)
Nil
}
else if (shouldStopWithInfo) {
- ctx.println(infoMessage)
+ ctx.echo(infoMessage)
Nil
} else {
- if (sourcesRequired && summary.arguments.isEmpty) ctx.println(usageMessage)
+ if (sourcesRequired && summary.arguments.isEmpty) ctx.echo(usageMessage)
summary.arguments
}
}
diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala
index 6e7eed3bc..946738d73 100644
--- a/src/dotty/tools/dotc/core/Denotations.scala
+++ b/src/dotty/tools/dotc/core/Denotations.scala
@@ -464,7 +464,7 @@ object Denotations {
try info.signature
catch { // !!! DEBUG
case scala.util.control.NonFatal(ex) =>
- ctx.println(s"cannot take signature of ${info.show}")
+ ctx.echo(s"cannot take signature of ${info.show}")
throw ex
}
case _ => Signature.NotAMethod
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index dbee86549..a10b1fd0e 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -1295,10 +1295,10 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
def showGoal(tp1: Type, tp2: Type)(implicit ctx: Context) = {
println(disambiguated(implicit ctx => s"assertion failure for ${tp1.show} <:< ${tp2.show}, frozen = $frozenConstraint"))
def explainPoly(tp: Type) = tp match {
- case tp: PolyParam => ctx.println(s"polyparam ${tp.show} found in ${tp.binder.show}")
- case tp: TypeRef if tp.symbol.exists => ctx.println(s"typeref ${tp.show} found in ${tp.symbol.owner.show}")
- case tp: TypeVar => ctx.println(s"typevar ${tp.show}, origin = ${tp.origin}")
- case _ => ctx.println(s"${tp.show} is a ${tp.getClass}")
+ case tp: PolyParam => ctx.echo(s"polyparam ${tp.show} found in ${tp.binder.show}")
+ case tp: TypeRef if tp.symbol.exists => ctx.echo(s"typeref ${tp.show} found in ${tp.symbol.owner.show}")
+ case tp: TypeVar => ctx.echo(s"typevar ${tp.show}, origin = ${tp.origin}")
+ case _ => ctx.echo(s"${tp.show} is a ${tp.getClass}")
}
explainPoly(tp1)
explainPoly(tp2)
diff --git a/src/dotty/tools/dotc/reporting/Reporter.scala b/src/dotty/tools/dotc/reporting/Reporter.scala
index 44defa6b1..e4169b1fd 100644
--- a/src/dotty/tools/dotc/reporting/Reporter.scala
+++ b/src/dotty/tools/dotc/reporting/Reporter.scala
@@ -51,9 +51,9 @@ trait Reporting { this: Context =>
/** For sending messages that are printed only if -verbose is set */
def inform(msg: => String, pos: SourcePosition = NoSourcePosition): Unit =
- if (this.settings.verbose.value) this.println(msg, pos)
+ if (this.settings.verbose.value) this.echo(msg, pos)
- def println(msg: => String, pos: SourcePosition = NoSourcePosition): Unit =
+ def echo(msg: => String, pos: SourcePosition = NoSourcePosition): Unit =
reporter.report(new Info(msg, pos))
def deprecationWarning(msg: => String, pos: SourcePosition = NoSourcePosition): Unit =
@@ -95,7 +95,7 @@ trait Reporting { this: Context =>
*/
def log(msg: => String, pos: SourcePosition = NoSourcePosition): Unit =
if (this.settings.log.value.containsPhase(phase))
- this.println(s"[log ${ctx.phasesStack.reverse.mkString(" -> ")}] $msg", pos)
+ echo(s"[log ${ctx.phasesStack.reverse.mkString(" -> ")}] $msg", pos)
def debuglog(msg: => String): Unit =
if (ctx.debug) log(msg)
@@ -243,8 +243,7 @@ abstract class Reporter extends interfaces.ReporterResult {
/** Print the summary of warnings and errors */
def printSummary(implicit ctx: Context): Unit = {
val s = summary
- if (s != "")
- ctx.println(s)
+ if (s != "") ctx.echo(s)
}
/** Returns a string meaning "n elements". */
diff --git a/src/dotty/tools/dotc/rewrite/Rewrites.scala b/src/dotty/tools/dotc/rewrite/Rewrites.scala
index 7ab0e5d59..c42c808fe 100644
--- a/src/dotty/tools/dotc/rewrite/Rewrites.scala
+++ b/src/dotty/tools/dotc/rewrite/Rewrites.scala
@@ -75,7 +75,7 @@ object Rewrites {
*/
def writeBack()(implicit ctx: Context) =
for (rewrites <- ctx.settings.rewrite.value; source <- rewrites.patched.keys) {
- ctx.println(s"[patched file ${source.file.path}]")
+ ctx.echo(s"[patched file ${source.file.path}]")
rewrites.patched(source).writeBack()
}
}
diff --git a/src/dotty/tools/dotc/transform/TreeChecker.scala b/src/dotty/tools/dotc/transform/TreeChecker.scala
index f11789c9a..a27c9c5f3 100644
--- a/src/dotty/tools/dotc/transform/TreeChecker.scala
+++ b/src/dotty/tools/dotc/transform/TreeChecker.scala
@@ -52,7 +52,7 @@ class TreeChecker extends Phase with SymTransformer {
!name.exists(c => c == '.' || c == ';' || c =='[' || c == '/' || c == '<' || c == '>')
def printError(str: String)(implicit ctx: Context) = {
- ctx.println(Console.RED + "[error] " + Console.WHITE + str)
+ ctx.echo(Console.RED + "[error] " + Console.WHITE + str)
}
val NoSuperClass = Trait | Package
@@ -118,17 +118,17 @@ class TreeChecker extends Phase with SymTransformer {
def check(phasesToRun: Seq[Phase], ctx: Context) = {
val prevPhase = ctx.phase.prev // can be a mini-phase
val squahsedPhase = ctx.squashed(prevPhase)
- ctx.println(s"checking ${ctx.compilationUnit} after phase ${squahsedPhase}")
+ ctx.echo(s"checking ${ctx.compilationUnit} after phase ${squahsedPhase}")
val checkingCtx = ctx.fresh.setReporter(new ThrowingReporter(ctx.reporter))
val checker = new Checker(previousPhases(phasesToRun.toList)(ctx))
try checker.typedExpr(ctx.compilationUnit.tpdTree)(checkingCtx)
catch {
case NonFatal(ex) => //TODO CHECK. Check that we are bootstrapped
implicit val ctx: Context = checkingCtx
- ctx.println(i"*** error while checking ${ctx.compilationUnit} after phase ${checkingCtx.phase.prev} ***")
- ctx.println(ex.toString)
- ctx.println(ex.getStackTrace.take(30).deep.mkString("\n"))
- ctx.println("<<<")
+ ctx.echo(i"*** error while checking ${ctx.compilationUnit} after phase ${checkingCtx.phase.prev} ***")
+ ctx.echo(ex.toString)
+ ctx.echo(ex.getStackTrace.take(30).deep.mkString("\n"))
+ ctx.echo("<<<")
throw ex
}
}
@@ -163,10 +163,10 @@ class TreeChecker extends Phase with SymTransformer {
}
nowDefinedSyms += tree.symbol
- //ctx.println(i"defined: ${tree.symbol}")
+ //ctx.echo(i"defined: ${tree.symbol}")
val res = op
nowDefinedSyms -= tree.symbol
- //ctx.println(i"undefined: ${tree.symbol}")
+ //ctx.echo(i"undefined: ${tree.symbol}")
res
case _ => op
}
diff --git a/src/dotty/tools/dotc/typer/FrontEnd.scala b/src/dotty/tools/dotc/typer/FrontEnd.scala
index eee8744a5..c5c6aec3c 100644
--- a/src/dotty/tools/dotc/typer/FrontEnd.scala
+++ b/src/dotty/tools/dotc/typer/FrontEnd.scala
@@ -23,7 +23,7 @@ class FrontEnd extends Phase {
try body
catch {
case NonFatal(ex) =>
- ctx.println(s"exception occurred while $doing ${ctx.compilationUnit}")
+ ctx.echo(s"exception occurred while $doing ${ctx.compilationUnit}")
throw ex
}