aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2016-09-21 10:09:13 +0200
committerFelix Mulder <felix.mulder@gmail.com>2016-10-10 13:25:35 +0200
commitaa559359bb55729913d34588462542f10c42e147 (patch)
treea42ca5b5e1b58dfa735c5239c04bd5e838d95d48 /src/dotty/tools/dotc/reporting/diagnostic/messages.scala
parent8743fa86e25133d0ddea3d85d7df0a5ceadef83a (diff)
downloaddotty-aa559359bb55729913d34588462542f10c42e147.tar.gz
dotty-aa559359bb55729913d34588462542f10c42e147.tar.bz2
dotty-aa559359bb55729913d34588462542f10c42e147.zip
Refactor explanation interpolator
Diffstat (limited to 'src/dotty/tools/dotc/reporting/diagnostic/messages.scala')
-rw-r--r--src/dotty/tools/dotc/reporting/diagnostic/messages.scala27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
index cf67e8989..009636593 100644
--- a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
+++ b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
@@ -4,12 +4,13 @@ package reporting
package diagnostic
import dotc.core._
-import Contexts.Context, Decorators._, Symbols._, Names._
+import Contexts.Context, Decorators._, Symbols._, Names._, Types._
import util.{SourceFile, NoSource}
import util.{SourcePosition, NoSourcePosition}
import config.Settings.Setting
import interfaces.Diagnostic.{ERROR, WARNING, INFO}
-import dotc.printing.SyntaxHighlighting._
+import printing.SyntaxHighlighting._
+import printing.Formatting
object messages {
@@ -127,7 +128,7 @@ object messages {
}
}
- class EmptyCatchBlock(tryBody: untpd.Tree)(implicit ctx: Context)
+ case class EmptyCatchBlock(tryBody: untpd.Tree)(implicit ctx: Context)
extends EmptyCatchOrFinallyBlock(tryBody, "E001") {
val kind = "Syntax"
val msg =
@@ -174,7 +175,7 @@ object messages {
}
/** Type Errors ----------------------------------------------------------- */
- class DuplicateBind(bind: untpd.Bind, tree: untpd.CaseDef)(implicit ctx: Context)
+ case class DuplicateBind(bind: untpd.Bind, tree: untpd.CaseDef)(implicit ctx: Context)
extends Message("E004") {
val kind = "Naming"
val msg = em"duplicate pattern variable: `${bind.name}`"
@@ -201,9 +202,9 @@ object messages {
}
}
- class MissingIdent(tree: untpd.Ident, treeKind: String, name: Name)(implicit ctx: Context)
+ case class MissingIdent(tree: untpd.Ident, treeKind: String, name: Name)(implicit ctx: Context)
extends Message("E005") {
- val kind = "Missing identifier"
+ val kind = "Missing Identifier"
val msg = em"not found: $treeKind$name"
val explanation = {
@@ -211,4 +212,18 @@ object messages {
|has either been misspelt or you're forgetting an import""".stripMargin
}
}
+
+ case class TypeMismatch(found: Type, expected: Type, whyNoMatch: String = "")(implicit ctx: Context)
+ extends Message("E006") {
+ val kind = "Type Mismatch"
+ private val where = Formatting.disambiguateTypes(found, expected)
+ private val (fnd, exp) = Formatting.typeDiff(found, expected)
+ val msg =
+ s"""|found: $fnd
+ |required: $exp
+ |
+ |$where""".stripMargin + whyNoMatch
+
+ val explanation = ""
+ }
}