diff --git a/compiler/src/dotty/tools/dotc/reporting/messages.scala b/compiler/src/dotty/tools/dotc/reporting/messages.scala index 0218d8a9c915..7f0bd8ed6e17 100644 --- a/compiler/src/dotty/tools/dotc/reporting/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/messages.scala @@ -1739,10 +1739,12 @@ class NotAPath(tp: Type, usage: String)(using Context) extends TypeMsg(NotAPathI | - a reference to `this`, or | - a selection of an immutable path with an immutable value.""" -class WrongNumberOfParameters(expected: Int)(using Context) +class WrongNumberOfParameters(expected: Int, found: Int, pt: Type, tree: tpd.Tree)(using Context) extends SyntaxMsg(WrongNumberOfParametersID) { - def msg(using Context) = s"Wrong number of parameters, expected: $expected" - def explain(using Context) = "" + def msg(using Context) = s"Wrong number of parameters, expected $expected, but found $found" + def explain(using Context) = + i"""|Expected pattern: $pt + |Found pattern : ${tree.srcPos}""" } class DuplicatePrivateProtectedQualifier()(using Context) diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 2e7444af8e96..9ee77f4aa418 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -1569,7 +1569,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer /** Returns the type and whether the parameter is erased */ def protoFormal(i: Int): (Type, Boolean) = if (protoFormals.length == params.length) (protoFormals(i), isDefinedErased(i)) - else (errorType(WrongNumberOfParameters(protoFormals.length), tree.srcPos), false) + else (errorType(WrongNumberOfParameters(protoFormals.length, params.length, pt, tree), tree.srcPos), false) /** Is `formal` a product type which is elementwise compatible with `params`? */ def ptIsCorrectProduct(formal: Type) =