diff options
author | Martin Odersky <odersky@gmail.com> | 2014-08-28 18:31:13 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-08-28 18:31:13 +0200 |
commit | f7d3f3b12e0f3f69954bfb9980134968abf541f5 (patch) | |
tree | df84adc9cb0cda638b40525e988610074430ff1a | |
parent | 11ffd9ed2df33299351fdb2db7bccbafa3806a0b (diff) | |
download | dotty-f7d3f3b12e0f3f69954bfb9980134968abf541f5.tar.gz dotty-f7d3f3b12e0f3f69954bfb9980134968abf541f5.tar.bz2 dotty-f7d3f3b12e0f3f69954bfb9980134968abf541f5.zip |
Better error diadnostics in TreeChecker.
On type error, show the source line where the failure occured.
-rw-r--r-- | src/dotty/tools/dotc/transform/TreeChecker.scala | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/transform/TreeChecker.scala b/src/dotty/tools/dotc/transform/TreeChecker.scala index 7147d3b15..2edaabdf2 100644 --- a/src/dotty/tools/dotc/transform/TreeChecker.scala +++ b/src/dotty/tools/dotc/transform/TreeChecker.scala @@ -17,6 +17,7 @@ import typer.ErrorReporting._ import reporting.ThrowingReporter import ast.Trees._ import ast.{tpd, untpd} +import util.SourcePosition import java.lang.AssertionError /** Run by -Ycheck option after a given phase, this class retypes all syntax trees @@ -111,7 +112,10 @@ class TreeChecker { } override def adapt(tree: Tree, pt: Type, original: untpd.Tree = untpd.EmptyTree)(implicit ctx: Context) = { - if (ctx.mode.isExpr) assert(tree.tpe <:< pt, err.typeMismatchStr(tree.tpe, pt)) + if (ctx.mode.isExpr) + assert(tree.tpe <:< pt, + s"error at ${sourcePos(tree.pos)}\n" + + err.typeMismatchStr(tree.tpe, pt)) tree } } |