aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/reporting
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2016-11-07 13:12:26 +0100
committerFelix Mulder <felix.mulder@gmail.com>2016-11-07 14:05:47 +0100
commit1fec582b4e85de715e92ccb621ac55e02874558e (patch)
tree6fde544794cb073ba8690b4b7e46162ce902c951 /src/dotty/tools/dotc/reporting
parent98c6a0342f2903f8cbaf34e0f9a13be40916c7b4 (diff)
downloaddotty-1fec582b4e85de715e92ccb621ac55e02874558e.tar.gz
dotty-1fec582b4e85de715e92ccb621ac55e02874558e.tar.bz2
dotty-1fec582b4e85de715e92ccb621ac55e02874558e.zip
Inline iff reporter has no new errors post typing `rhs`
Diffstat (limited to 'src/dotty/tools/dotc/reporting')
-rw-r--r--src/dotty/tools/dotc/reporting/Reporter.scala16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/reporting/Reporter.scala b/src/dotty/tools/dotc/reporting/Reporter.scala
index b38334412..49bd3e811 100644
--- a/src/dotty/tools/dotc/reporting/Reporter.scala
+++ b/src/dotty/tools/dotc/reporting/Reporter.scala
@@ -167,6 +167,22 @@ trait Reporting { this: Context =>
throw ex
}
}
+
+ /** Implements a fold that applies the function `f` to the result of `op` if
+ * there are no new errors in the reporter
+ *
+ * @param op operation checked for errors
+ * @param f function applied to result of op
+ * @return either the result of `op` if it had errors or the result of `f`
+ * applied to it
+ */
+ def withNoError[A, B >: A](op: => A)(f: A => B): B = {
+ val before = reporter.errorCount
+ val op0 = op
+
+ if (reporter.errorCount > before) op0
+ else f(op0)
+ }
}
/**