diff --git a/compiler/src/dotty/tools/dotc/reporting/ErrorMessageID.scala b/compiler/src/dotty/tools/dotc/reporting/ErrorMessageID.scala index 7b22eb77e90e..d9140a6309b8 100644 --- a/compiler/src/dotty/tools/dotc/reporting/ErrorMessageID.scala +++ b/compiler/src/dotty/tools/dotc/reporting/ErrorMessageID.scala @@ -67,7 +67,7 @@ enum ErrorMessageID(val isActive: Boolean = true) extends java.lang.Enum[ErrorMe case AmbiguousOverloadID // errorNumber: 51 case ReassignmentToValID // errorNumber: 52 case TypeDoesNotTakeParametersID // errorNumber: 53 - case ParameterizedTypeLacksArgumentsID // errorNumber: 54 + case ParameterizedTypeLacksArgumentsID extends ErrorMessageID(isActive = false) // errorNumber: 54 case VarValParametersMayNotBeCallByNameID // errorNumber: 55 case MissingTypeParameterForID // errorNumber: 56 case DoesNotConformToBoundID // errorNumber: 57 @@ -184,7 +184,8 @@ enum ErrorMessageID(val isActive: Boolean = true) extends java.lang.Enum[ErrorMe case ImplicitSearchTooLargeID // errorNumber: 168 case TargetNameOnTopLevelClassID // errorNumber: 169 case NotClassTypeID // errorNumber 170 - + case MissingArgumentID // errorNumer 171 + def errorNumber = ordinal - 1 object ErrorMessageID: diff --git a/compiler/src/dotty/tools/dotc/reporting/messages.scala b/compiler/src/dotty/tools/dotc/reporting/messages.scala index a3af4c1b2582..56375d881f97 100644 --- a/compiler/src/dotty/tools/dotc/reporting/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/messages.scala @@ -1406,15 +1406,6 @@ import cc.CaptureSet.IdentityCaptRefMap |""" } - class ParameterizedTypeLacksArguments(psym: Symbol)(using Context) - extends TypeMsg(ParameterizedTypeLacksArgumentsID) { - def msg = em"Parameterized $psym lacks argument list" - def explain = - em"""The $psym is declared with non-implicit parameters, you may not leave - |out the parameter list when extending it. - |""" - } - class VarValParametersMayNotBeCallByName(name: TermName, mutable: Boolean)(using Context) extends SyntaxMsg(VarValParametersMayNotBeCallByNameID) { def varOrVal = if (mutable) em"${hl("var")}" else em"${hl("val")}" @@ -1445,6 +1436,13 @@ import cc.CaptureSet.IdentityCaptRefMap def explain = em"A fully applied type is expected but $tpe takes $numParams $parameters" } + class MissingArgument(pname: Name, methString: String)(using Context) + extends TypeMsg(MissingArgumentID): + def msg = + if pname.firstPart contains '$' then s"not enough arguments for $methString" + else s"missing argument for parameter $pname of $methString" + def explain = "" + class DoesNotConformToBound(tpe: Type, which: String, bound: Type)(using Context) extends TypeMismatchMsg( if which == "lower" then bound else tpe, @@ -2535,3 +2533,4 @@ import cc.CaptureSet.IdentityCaptRefMap extends TypeMsg(NotClassTypeID), ShowMatchTrace(tp): def msg = ex"$tp is not a class type" def explain = "" + diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index b4f3da25fc6c..825a0c15f75c 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -561,12 +561,8 @@ trait Applications extends Compatibility { else formals1 - def missingArg(n: Int): Unit = { - val pname = methodType.paramNames(n) - fail( - if (pname.firstPart contains '$') s"not enough arguments for $methString" - else s"missing argument for parameter $pname of $methString") - } + def missingArg(n: Int): Unit = + fail(MissingArgument(methodType.paramNames(n), methString)) def tryDefault(n: Int, args1: List[Arg]): Unit = { val sym = methRef.symbol diff --git a/compiler/test/dotty/tools/repl/ShadowingTests.scala b/compiler/test/dotty/tools/repl/ShadowingTests.scala index 1ba58a4babff..62a2322e38f0 100644 --- a/compiler/test/dotty/tools/repl/ShadowingTests.scala +++ b/compiler/test/dotty/tools/repl/ShadowingTests.scala @@ -80,7 +80,7 @@ class ShadowingTests extends ReplTest(options = ShadowingTests.options): shadowed = "class C(val c: Int)", script = """|scala> new C().c - |-- Error: ---------------------------------------------------------------------- + |-- [E171] Type Error: ---------------------------------------------------------- |1 | new C().c | | ^^^^^^^ | | missing argument for parameter c of constructor C in class C: (c: Int): C diff --git a/tests/neg/i16130.check b/tests/neg/i16130.check new file mode 100644 index 000000000000..7ee7a821a32b --- /dev/null +++ b/tests/neg/i16130.check @@ -0,0 +1,4 @@ +-- [E171] Type Error: tests/neg/i16130.scala:3:16 ---------------------------------------------------------------------- +3 | val foo = new Foo {} // error + | ^^^ + | missing argument for parameter x of constructor Foo in trait Foo: (x: Int): Foo diff --git a/tests/neg/i16130.scala b/tests/neg/i16130.scala new file mode 100644 index 000000000000..ce7ba8e18b3d --- /dev/null +++ b/tests/neg/i16130.scala @@ -0,0 +1,3 @@ +@main def ParameterizedTypeLacksArgumentsID = + trait Foo(x: Int) + val foo = new Foo {} // error diff --git a/tests/neg/i6778.check b/tests/neg/i6778.check index 0dcce319dd7f..2287811ee361 100644 --- a/tests/neg/i6778.check +++ b/tests/neg/i6778.check @@ -4,7 +4,7 @@ | class A is not a trait | | longer explanation available when compiling with `-explain` --- Error: tests/neg/i6778.scala:3:6 ------------------------------------------------------------------------------------ +-- [E171] Type Error: tests/neg/i6778.scala:3:6 ------------------------------------------------------------------------ 3 |class Bar extends Foo with A(10) // error // error | ^ | missing argument for parameter x of constructor A in class A: (x: Int): A diff --git a/tests/neg/i9436.check b/tests/neg/i9436.check index b5f9b5c470b1..d8e87fb54930 100644 --- a/tests/neg/i9436.check +++ b/tests/neg/i9436.check @@ -4,7 +4,7 @@ | method f1 must be called with () argument | | longer explanation available when compiling with `-explain` --- Error: tests/neg/i9436.scala:9:14 ----------------------------------------------------------------------------------- +-- [E171] Type Error: tests/neg/i9436.scala:9:14 ----------------------------------------------------------------------- 9 | println(x.f2(1)) // error | ^^^^^^^ | missing argument for parameter y of method f2: (x: Int, y: Int): Int