From b3256eda6631fc0db5bb9440a6b77e2186053b3f Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Fri, 3 Sep 2010 14:20:07 +0000 Subject: better error message for default arguments. --- src/compiler/scala/tools/nsc/typechecker/Typers.scala | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index a003a4fd7e..7dc2f56197 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2371,6 +2371,9 @@ trait Typers { self: Analyzer => val funSym = fun1 match { case Block(_, expr) => expr.symbol } if (allArgs.length != args.length && callToCompanionConstr(context, funSym)) { errorTree(tree, "module extending its companion class cannot use default constructor arguments") + } else if (allArgs.length > formals.length) { + removeNames(Typer.this)(allArgs, params) // #3818 + setError(tree) } else if (allArgs.length == formals.length) { // useful when a default doesn't match parameter type, e.g. def f[T](x:T="a"); f[Int]() val note = "Error occurred in an application involving default arguments." -- cgit v1.2.3