aboutsummaryrefslogtreecommitdiff
path: root/compiler/src
diff options
context:
space:
mode:
authorEnno Runne <enno@runne.net>2017-02-20 22:12:44 +0100
committerEnno Runne <enno@runne.net>2017-02-20 22:12:44 +0100
commit40ce201bb8087503b6f55f49c67980318fc1bfdb (patch)
tree64eac4960e67bc551d70aebe37c7a36e0ff13b92 /compiler/src
parentf467be62da8978e506f58b702b84e74ef7ce09de (diff)
downloaddotty-40ce201bb8087503b6f55f49c67980318fc1bfdb.tar.gz
dotty-40ce201bb8087503b6f55f49c67980318fc1bfdb.tar.bz2
dotty-40ce201bb8087503b6f55f49c67980318fc1bfdb.zip
Change 'is abstract; cannot be instantiated' to Message
Diffstat (limited to 'compiler/src')
-rw-r--r--compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java4
-rw-r--r--compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala8
-rw-r--r--compiler/src/dotty/tools/dotc/typer/Checking.scala3
3 files changed, 13 insertions, 2 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 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 = ""
+ }
+
}
diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala
index fb0497c2b..48f9243f7 100644
--- a/compiler/src/dotty/tools/dotc/typer/Checking.scala
+++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala
@@ -29,6 +29,7 @@ import ErrorReporting.{err, errorType}
import config.Printers.typr
import collection.mutable
import SymDenotations.NoCompleter
+import dotty.tools.dotc.reporting.diagnostic.messages.CantInstantiateAbstractClassOrTrait
import dotty.tools.dotc.transform.ValueClasses._
object Checking {
@@ -103,7 +104,7 @@ object Checking {
case tref: TypeRef =>
val cls = tref.symbol
if (cls.is(AbstractOrTrait))
- ctx.error(em"$cls is abstract; cannot be instantiated", pos)
+ ctx.error(CantInstantiateAbstractClassOrTrait(cls, isTrait = cls.is(Trait)), pos)
if (!cls.is(Module)) {
// Create a synthetic singleton type instance, and check whether
// it conforms to the self type of the class as seen from that instance.