From 40ce201bb8087503b6f55f49c67980318fc1bfdb Mon Sep 17 00:00:00 2001 From: Enno Runne Date: Mon, 20 Feb 2017 22:12:44 +0100 Subject: Change 'is abstract; cannot be instantiated' to Message --- .../src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java | 4 +++- compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'compiler/src/dotty/tools/dotc/reporting') 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 7fccebef9..1ad606076 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -1127,4 +1127,12 @@ 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 = "" + } + } -- cgit v1.2.3 From 3c2b09f2a16d04b7f5c10c87faba14c62e5896a4 Mon Sep 17 00:00:00 2001 From: Enno Runne Date: Wed, 22 Feb 2017 20:13:20 +0100 Subject: Added explanation for CantInstatiateAbstractClassOrTrait --- .../dotty/tools/dotc/reporting/diagnostic/messages.scala | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'compiler/src/dotty/tools/dotc/reporting') diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index 1ad606076..03af81770 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -1132,7 +1132,18 @@ object messages { 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 = "" + 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 } } -- cgit v1.2.3