aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/reporting/Reporter.scala
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2015-11-24 21:32:50 +0100
committerGuillaume Martres <smarter@ubuntu.com>2015-11-26 16:49:31 +0100
commitbd079c7a271b4bc8007021b34de6bbacea9fa85f (patch)
tree8974685026d5b2783efbbc0beca4c75d78cb6362 /src/dotty/tools/dotc/reporting/Reporter.scala
parentec2d0e46a608cad7c53d7eb0154e89b19d73f973 (diff)
downloaddotty-bd079c7a271b4bc8007021b34de6bbacea9fa85f.tar.gz
dotty-bd079c7a271b4bc8007021b34de6bbacea9fa85f.tar.bz2
dotty-bd079c7a271b4bc8007021b34de6bbacea9fa85f.zip
Avoid repeated unnecessary logging in traceIndented
While trying to debug #943 I noticed that the exception output from traceIndented was interspersed with unrelated logging output, this happened because `question` in traceIndented is by-name and was evaluated both before executing an operation and afterwards.
Diffstat (limited to 'src/dotty/tools/dotc/reporting/Reporter.scala')
-rw-r--r--src/dotty/tools/dotc/reporting/Reporter.scala7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/reporting/Reporter.scala b/src/dotty/tools/dotc/reporting/Reporter.scala
index 4a72c2066..5cad0a077 100644
--- a/src/dotty/tools/dotc/reporting/Reporter.scala
+++ b/src/dotty/tools/dotc/reporting/Reporter.scala
@@ -152,7 +152,12 @@ trait Reporting { this: Context =>
case _ => String.valueOf(res)
}
if (printer eq config.Printers.noPrinter) op
- else traceIndented[T](s"==> $question?", (res: Any) => s"<== $question = ${resStr(res)}")(op)
+ else {
+ // Avoid evaluating question multiple time, since each evaluation
+ // may cause some extra logging output.
+ val q: String = question
+ traceIndented[T](s"==> $q?", (res: Any) => s"<== $q = ${resStr(res)}")(op)
+ }
}
def traceIndented[T](leading: => String, trailing: Any => String)(op: => T): T =