aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-12-10 22:02:06 +0100
committerMartin Odersky <odersky@gmail.com>2013-12-10 22:02:06 +0100
commita2e1606a03b1ebd7553ee6f10b04227bfd69c9e1 (patch)
tree48c80fb042414c84f6744bbd3b1d21f665aaeb9a /src
parenteb0813b9ef437b9c89f8b67ae5b0070b300a0fc1 (diff)
downloaddotty-a2e1606a03b1ebd7553ee6f10b04227bfd69c9e1.tar.gz
dotty-a2e1606a03b1ebd7553ee6f10b04227bfd69c9e1.tar.bz2
dotty-a2e1606a03b1ebd7553ee6f10b04227bfd69c9e1.zip
Fixing a problem with swallowed errors
The problem was that in FunProto#typedArg we cache typed arguments, to retrieve them later, possibly in a different context (Example: typedArg might be computed during overloading resolution, and then cached copy might be inserted in resolved call. The problem is that any errors, warnings or other diagnostics might be swallowed, if typedArg is computed in a context that is not committed but then re-used in a committed context. The fix is to cache typed arguments only if no diagnostics were issued during their computation.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/reporting/Reporter.scala11
-rw-r--r--src/dotty/tools/dotc/typer/Inferencing.scala7
2 files changed, 15 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/reporting/Reporter.scala b/src/dotty/tools/dotc/reporting/Reporter.scala
index 72b9247c5..6e7a79306 100644
--- a/src/dotty/tools/dotc/reporting/Reporter.scala
+++ b/src/dotty/tools/dotc/reporting/Reporter.scala
@@ -219,6 +219,17 @@ abstract class Reporter {
def hasErrors = count(ERROR.level) > 0
def hasWarnings = count(WARNING.level) > 0
+ def isSilent[T](op: => Unit): Boolean = {
+ val prevCount = count.clone
+ op
+ var i = 0
+ while (i < count.length) {
+ if (prevCount(i) != count(i)) return false
+ i += 1
+ }
+ true
+ }
+
/** Returns a string meaning "n elements". */
private def countElementsAsString(n: Int, elements: String): String =
n match {
diff --git a/src/dotty/tools/dotc/typer/Inferencing.scala b/src/dotty/tools/dotc/typer/Inferencing.scala
index 3dac39854..ddd95fde1 100644
--- a/src/dotty/tools/dotc/typer/Inferencing.scala
+++ b/src/dotty/tools/dotc/typer/Inferencing.scala
@@ -110,13 +110,14 @@ object Inferencing {
}
/** Type single argument and remember the unadapted result in `myTypedArg`.
- * used to avoid repreated typings of trees when backtracking.
+ * used to avoid repeated typings of trees when backtracking.
*/
def typedArg(arg: untpd.Tree, formal: Type)(implicit ctx: Context): Tree = {
var targ = myTypedArg(arg)
if (targ == null) {
- targ = typer.typedUnadapted(arg, formal)
- myTypedArg = myTypedArg.updated(arg, targ)
+ if (ctx.typerState.reporter.isSilent {
+ targ = typer.typedUnadapted(arg, formal)
+ }) myTypedArg = myTypedArg.updated(arg, targ)
}
typer.adapt(targ, formal)
}