aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/reporting
diff options
context:
space:
mode:
authorAbel Nieto <abeln@google.com>2017-03-16 15:49:06 -0400
committerFelix Mulder <felix.mulder@gmail.com>2017-03-17 18:54:19 +0100
commitd0621108bad55f9fc66c1c5ade9a0b7edb3117e7 (patch)
treec8374913e8a724e80cd773ef7f3438500beb125e /compiler/src/dotty/tools/dotc/reporting
parent2325863c216e2bf4f7ad0f366bb80ef866ff6b79 (diff)
downloaddotty-d0621108bad55f9fc66c1c5ade9a0b7edb3117e7.tar.gz
dotty-d0621108bad55f9fc66c1c5ade9a0b7edb3117e7.tar.bz2
dotty-d0621108bad55f9fc66c1c5ade9a0b7edb3117e7.zip
Move 'invalid super qualifier' error to new error format.
As part of https://github.com/lampepfl/dotty/issues/1589, use the new error message for static super references where the qualifier isn't a parent of the class. Tested: Added unit test.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/reporting')
-rw-r--r--compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java1
-rw-r--r--compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala17
2 files changed, 18 insertions, 0 deletions
diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java b/compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java
index 7b56c8ed4..6ea168b99 100644
--- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java
+++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java
@@ -55,6 +55,7 @@ public enum ErrorMessageID {
RecursiveValueNeedsResultTypeID,
CyclicReferenceInvolvingID,
CyclicReferenceInvolvingImplicitID,
+ SuperQualMustBeParentID,
;
public int errorNumber() {
diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
index 4c53fa496..6fa056646 100644
--- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
+++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
@@ -1192,4 +1192,21 @@ object messages {
|""".stripMargin
}
+ case class SuperQualMustBeParent(qual: untpd.Ident, cls: Symbols.ClassSymbol)(implicit ctx: Context)
+ extends Message(SuperQualMustBeParentID) {
+
+ val msg = hl"""|$qual does not name a parent of $cls"""
+
+ val kind = "Reference"
+
+ private val parents: Seq[String] = (cls.info.parents map (_.name.show)).sorted
+
+ val explanation =
+ hl"""|When a qualifier ${"T"} is used in a ${"super"} prefix of the form ${"C.super[T]"},
+ |${"T"} must be a parent type of ${"C"}.
+ |
+ |In this case, the parents of $cls are:
+ |${parents.mkString(" - ", "\n - ", "")}
+ |""".stripMargin
+ }
}