aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/reporting
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/src/dotty/tools/dotc/reporting')
-rw-r--r--compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java4
-rw-r--r--compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala19
2 files changed, 22 insertions, 1 deletions
diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java b/compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java
index c74130b44..2bf15cb7c 100644
--- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java
+++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java
@@ -49,7 +49,9 @@ public enum ErrorMessageID {
OverridesNothingButNameExistsID,
ForwardReferenceExtendsOverDefinitionID,
ExpectedTokenButFoundID,
- MixedLeftAndRightAssociativeOpsID;
+ MixedLeftAndRightAssociativeOpsID,
+ CantInstantiateAbstractClassOrTraitID,
+ ;
public int errorNumber() {
return ordinal() - 2;
diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
index e818e7a42..34190c114 100644
--- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
+++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
@@ -1127,4 +1127,23 @@ object messages {
|""".stripMargin
}
+ case class CantInstantiateAbstractClassOrTrait(cls: Symbol, isTrait: Boolean)(implicit ctx: Context)
+ extends Message(CantInstantiateAbstractClassOrTraitID) {
+ val kind = "Usage"
+ private val traitOrAbstract = if (isTrait) hl"a trait" else hl"abstract"
+ val msg = hl"""${cls.name} is ${traitOrAbstract}; it cannot be instantiated"""
+ val explanation =
+ hl"""|Abstract classes and traits need to be extended by a concrete class or object
+ |to make their functionality accessible.
+ |
+ |You may want to create an anonymous class extending ${cls.name} with
+ | ${s"class ${cls.name} { }"}
+ |
+ |or add a companion object with
+ | ${s"object ${cls.name} extends ${cls.name}"}
+ |
+ |You need to implement any abstract members in both cases.
+ |""".stripMargin
+ }
+
}