From 749934aeafecc65c865d92056467c08540add8cc Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 22 Aug 2013 14:24:49 +0200 Subject: More typer bug fixes and improvements in error messages --- src/dotty/tools/dotc/typer/ErrorReporting.scala | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/dotty/tools/dotc/typer/ErrorReporting.scala') diff --git a/src/dotty/tools/dotc/typer/ErrorReporting.scala b/src/dotty/tools/dotc/typer/ErrorReporting.scala index d95807e3c..177882688 100644 --- a/src/dotty/tools/dotc/typer/ErrorReporting.scala +++ b/src/dotty/tools/dotc/typer/ErrorReporting.scala @@ -63,16 +63,16 @@ object ErrorReporting { def patternConstrStr(tree: Tree): String = ??? - def typeMismatch(tree: Tree, pt: Type): Tree = { - val result = errorTree(tree, - i"""type mismatch: - | found : ${tree.tpe} - | required: $pt""".stripMargin) + def typeMismatch(tree: Tree, pt: Type): Tree = + errorTree(tree, typeMismatchStr(tree.tpe, pt)) + + def typeMismatchStr(found: Type, expected: Type) = { if (ctx.settings.explaintypes.value) - new ExplainingTypeComparer().isSubType(tree.tpe, pt) - result + new ExplainingTypeComparer().isSubType(found, expected) + i"""type mismatch: + | found : $found + | required: $expected""".stripMargin } - } def err(implicit ctx: Context): Errors = new Errors -- cgit v1.2.3