aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/reporting
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/reporting')
-rw-r--r--src/dotty/tools/dotc/reporting/ConsoleReporter.scala1
-rw-r--r--src/dotty/tools/dotc/reporting/UniqueMessagePositions.scala16
-rw-r--r--src/dotty/tools/dotc/reporting/diagnostic/messages.scala19
3 files changed, 26 insertions, 10 deletions
diff --git a/src/dotty/tools/dotc/reporting/ConsoleReporter.scala b/src/dotty/tools/dotc/reporting/ConsoleReporter.scala
index d96ff48a4..6ebd53bea 100644
--- a/src/dotty/tools/dotc/reporting/ConsoleReporter.scala
+++ b/src/dotty/tools/dotc/reporting/ConsoleReporter.scala
@@ -108,6 +108,7 @@ class ConsoleReporter(
|${Blue("Explanation")}
|${Blue("===========")}""".stripMargin)
printMessage(m.explanation)
+ if (m.explanation.lastOption != Some('\n')) printMessage("")
}
override def doReport(m: MessageContainer)(implicit ctx: Context): Unit = {
diff --git a/src/dotty/tools/dotc/reporting/UniqueMessagePositions.scala b/src/dotty/tools/dotc/reporting/UniqueMessagePositions.scala
index c5ff8cb6b..6fd971c2a 100644
--- a/src/dotty/tools/dotc/reporting/UniqueMessagePositions.scala
+++ b/src/dotty/tools/dotc/reporting/UniqueMessagePositions.scala
@@ -7,10 +7,8 @@ import util.{SourcePosition, SourceFile}
import core.Contexts.Context
import diagnostic.MessageContainer
-/**
- * This trait implements `isHidden` so that multiple messages per position
- * are suppressed, unless they are of increasing severity.
- */
+/** This trait implements `isHidden` so that multiple messages per position
+ * are suppressed, unless they are of increasing severity. */
trait UniqueMessagePositions extends Reporter {
private val positions = new mutable.HashMap[(SourceFile, Int), Int]
@@ -21,10 +19,14 @@ trait UniqueMessagePositions extends Reporter {
override def isHidden(m: MessageContainer)(implicit ctx: Context): Boolean =
super.isHidden(m) || {
m.pos.exists && {
- positions get (ctx.source, m.pos.point) match {
- case Some(level) if level >= m.level => true
- case _ => positions((ctx.source, m.pos.point)) = m.level; false
+ var shouldHide = false
+ for (pos <- m.pos.start to m.pos.end) {
+ positions get (ctx.source, pos) match {
+ case Some(level) if level >= m.level => shouldHide = true
+ case _ => positions((ctx.source, pos)) = m.level
+ }
}
+ shouldHide
}
}
}
diff --git a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
index 4553a2d22..14978449a 100644
--- a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
+++ b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
@@ -166,9 +166,22 @@ object messages {
}
}
+ case class CaseClassMissingParamList(cdef: untpd.TypeDef)(implicit ctx: Context)
+ extends Message(4) {
+ val kind = "Syntax"
+ val msg =
+ hl"""|A ${"case class"} must have at least one parameter list"""
+
+ val explanation =
+ hl"""|${cdef.name} must have at least one parameter list, if you would rather
+ |have a singleton representation of ${cdef.name}, use a "${"case object"}".
+ |Or, add an explicit `()' as a parameter list to ${cdef.name}.""".stripMargin
+ }
+
+
// Type Errors ------------------------------------------------------------ //
case class DuplicateBind(bind: untpd.Bind, tree: untpd.CaseDef)(implicit ctx: Context)
- extends Message(4) {
+ extends Message(5) {
val kind = "Naming"
val msg = em"duplicate pattern variable: `${bind.name}`"
@@ -195,7 +208,7 @@ object messages {
}
case class MissingIdent(tree: untpd.Ident, treeKind: String, name: String)(implicit ctx: Context)
- extends Message(5) {
+ extends Message(6) {
val kind = "Missing Identifier"
val msg = em"not found: $treeKind$name"
@@ -206,7 +219,7 @@ object messages {
}
case class TypeMismatch(found: Type, expected: Type, whyNoMatch: String = "", implicitFailure: String = "")(implicit ctx: Context)
- extends Message(6) {
+ extends Message(7) {
val kind = "Type Mismatch"
private val (where, printCtx) = Formatting.disambiguateTypes(found, expected)
private val (fnd, exp) = Formatting.typeDiff(found, expected)(printCtx)