diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-09-27 17:27:59 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-10-10 13:25:36 +0200 |
commit | 7561db09c19bff7871cfd96c327f6f7882480ebd (patch) | |
tree | 11ab91c7abd83b6b835d0eed7f81a85c7bf9c76c /src/dotty | |
parent | a7d3f6e1b85f772bb343c5d006fd1e4edc844a93 (diff) | |
download | dotty-7561db09c19bff7871cfd96c327f6f7882480ebd.tar.gz dotty-7561db09c19bff7871cfd96c327f6f7882480ebd.tar.bz2 dotty-7561db09c19bff7871cfd96c327f6f7882480ebd.zip |
Fix TypeMismatch not getting nonsensical tags in some cases
Thanks @smarter!
Diffstat (limited to 'src/dotty')
-rw-r--r-- | src/dotty/tools/dotc/reporting/diagnostic/messages.scala | 4 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/ErrorReporting.scala | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index 76b2fd3e9..034e14267 100644 --- a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -213,7 +213,7 @@ object messages { } } - case class TypeMismatch(found: Type, expected: Type, whyNoMatch: String = "")(implicit ctx: Context) + case class TypeMismatch(found: Type, expected: Type, whyNoMatch: String = "", implicitFailure: String = "")(implicit ctx: Context) extends Message("E006") { val kind = "Type Mismatch" private val (where, printCtx) = Formatting.disambiguateTypes(found, expected) @@ -222,7 +222,7 @@ object messages { s"""|found: $fnd |required: $exp | - |$where""".stripMargin + whyNoMatch + |$where""".stripMargin + whyNoMatch + implicitFailure val explanation = "" } diff --git a/src/dotty/tools/dotc/typer/ErrorReporting.scala b/src/dotty/tools/dotc/typer/ErrorReporting.scala index 1fd4fc96e..1d22dc646 100644 --- a/src/dotty/tools/dotc/typer/ErrorReporting.scala +++ b/src/dotty/tools/dotc/typer/ErrorReporting.scala @@ -102,7 +102,7 @@ object ErrorReporting { def patternConstrStr(tree: Tree): String = ??? def typeMismatch(tree: Tree, pt: Type, implicitFailure: SearchFailure = NoImplicitMatches): Tree = - errorTree(tree, typeMismatchMsg(normalize(tree.tpe, pt), pt) /*+ implicitFailure.postscript*/) + errorTree(tree, typeMismatchMsg(normalize(tree.tpe, pt), pt, implicitFailure.postscript)) /** A subtype log explaining why `found` does not conform to `expected` */ def whyNoMatchStr(found: Type, expected: Type) = @@ -111,7 +111,7 @@ object ErrorReporting { else "" - def typeMismatchMsg(found: Type, expected: Type) = { + def typeMismatchMsg(found: Type, expected: Type, postScript: String = "") = { // replace constrained polyparams and their typevars by their bounds where possible object reported extends TypeMap { def setVariance(v: Int) = variance = v @@ -133,7 +133,7 @@ object ErrorReporting { val found1 = reported(found) reported.setVariance(-1) val expected1 = reported(expected) - TypeMismatch(found1, expected1, whyNoMatchStr(found, expected)) + TypeMismatch(found1, expected1, whyNoMatchStr(found, expected), postScript) } /** Format `raw` implicitNotFound argument, replacing all |