From dcaf750be9f8615c23b041c408b4e841814cd264 Mon Sep 17 00:00:00 2001 From: Enno Runne Date: Sat, 13 May 2017 14:45:45 +0200 Subject: [PATCH] =?UTF-8?q?Move=20=C2=B4parameterized=20type=20lack=20argu?= =?UTF-8?q?ment=20list=C2=B4=20to=20error=20case=20class?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reporting/diagnostic/ErrorMessageID.java | 1 + .../dotc/reporting/diagnostic/messages.scala | 10 ++++++++++ compiler/src/dotty/tools/dotc/typer/Typer.scala | 2 +- .../dotc/reporting/ErrorMessagesTests.scala | 16 ++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java b/compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java index 5e892eac8a93..eae28e1ac435 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java @@ -61,6 +61,7 @@ public enum ErrorMessageID { AmbiguousOverloadID, ReassignmentToValID, TypeDoesNotTakeParametersID, + ParameterizedTypeLacksArgumentsID, ; 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 5d16406ef4a8..484b37456f6a 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -1326,4 +1326,14 @@ object messages { |declared to take any. |""" } + + case class ParameterizedTypeLacksArguments(psym: Symbol)(implicit ctx: Context) + extends Message(ParameterizedTypeLacksArgumentsID) { + val msg = hl"parameterized $psym lacks argument list" + val kind = "Reference" + val explanation = + hl"""The $psym is declared with non-implicit parameters, you may not leave + |out the parameter list when extending it. + |""" + } } diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index b1b39606c693..7ba39a78cd35 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -1286,7 +1286,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit case cinfo: MethodType => if (!ctx.erasedTypes) { // after constructors arguments are passed in super call. typr.println(i"constr type: $cinfo") - ctx.error(em"parameterized $psym lacks argument list", ref.pos) + ctx.error(ParameterizedTypeLacksArguments(psym), ref.pos) } ref case _ => diff --git a/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala b/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala index 586450cf2eb5..d45da3abdfd4 100644 --- a/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala +++ b/compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala @@ -457,4 +457,20 @@ class ErrorMessagesTests extends ErrorMessagesTest { assertEquals("WithOutParams", tpe.show) } + @Test def parameterizedTypeLacksParameters = + checkMessagesAfter("frontend") { + """ + |trait WithParams(s: String) + |class Extending extends WithParams + """.stripMargin + } + .expect { (ictx, messages) => + implicit val ctx: Context = ictx + val defn = ictx.definitions + + assertMessageCount(1, messages) + val ParameterizedTypeLacksArguments(symbol) :: Nil = messages + assertEquals("trait WithParams", symbol.show) + } + }