aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/ErrorReporting.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/typer/ErrorReporting.scala')
-rw-r--r--src/dotty/tools/dotc/typer/ErrorReporting.scala16
1 files changed, 8 insertions, 8 deletions
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