Skip to content

Move ´parameterized type lack argument list´ to error case class #2445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public enum ErrorMessageID {
AmbiguousOverloadID,
ReassignmentToValID,
TypeDoesNotTakeParametersID,
ParameterizedTypeLacksArgumentsID,
;

public int errorNumber() {
Expand Down
10 changes: 10 additions & 0 deletions compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
|"""
}
}
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 _ =>
Expand Down
16 changes: 16 additions & 0 deletions compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

}