diff options
-rw-r--r-- | src/dotty/tools/dotc/typer/ErrorReporting.scala | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/ErrorReporting.scala b/src/dotty/tools/dotc/typer/ErrorReporting.scala index d3303628e..6f7d427cb 100644 --- a/src/dotty/tools/dotc/typer/ErrorReporting.scala +++ b/src/dotty/tools/dotc/typer/ErrorReporting.scala @@ -113,9 +113,23 @@ object ErrorReporting { case tp: TypeRef => s"with info ${tp.info} / ${tp.prefix.toString} / ${tp.prefix.dealias.toString}" case _ => "" } + // replace constrained polyparams and their typevars by their bounds where possible + val reported = new TypeMap { + def apply(tp: Type): Type = tp match { + case tp: PolyParam => + val e = ctx.typerState.constraint.entry(tp) + if (e.exists) + if (variance > 0) e.bounds.hi + else if (variance < 0) e.bounds.lo + else tp + else tp + case tp: TypeVar => apply(tp.stripTypeVar) + case _ => mapOver(tp) + } + } d"""type mismatch: | found : $found - | required: $expected""".stripMargin + whyNoMatchStr(found, expected) + | required: ${reported(expected)}""".stripMargin + whyNoMatchStr(found, expected) } /** Format `raw` implicitNotFound argument, replacing all |