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 --- .../tools/dotc/reporting/ErrorMessagesTests.scala | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'compiler/test') diff --git a/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala b/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala index 37d1404bb..971a40a1b 100644 --- a/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala +++ b/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala @@ -159,4 +159,43 @@ class ErrorMessagesTests extends ErrorMessagesTest { assertEquals("+:", op2.show) assertFalse(op2LeftAssoc) } + + @Test def cantInstantiateAbstract = + checkMessagesAfter("refchecks") { + """ + |object Scope { + | abstract class Concept + | new Concept() + |} + """.stripMargin + } + .expect { (ictx, messages) => + implicit val ctx: Context = ictx + val defn = ictx.definitions + + assertMessageCount(1, messages) + val CantInstantiateAbstractClassOrTrait(cls, isTrait) :: Nil = messages + assertEquals("Concept", cls.name.show) + assertFalse("expected class", isTrait) + } + + @Test def cantInstantiateTrait = + checkMessagesAfter("refchecks") { + """ + |object Scope { + | trait Concept + | new Concept() + |} + """.stripMargin + } + .expect { (ictx, messages) => + implicit val ctx: Context = ictx + val defn = ictx.definitions + + assertMessageCount(1, messages) + val CantInstantiateAbstractClassOrTrait(cls, isTrait) :: Nil = messages + assertEquals("Concept", cls.name.show) + assertTrue("expected trait", isTrait) + } + } -- cgit v1.2.3