diff options
author | Martin Odersky <odersky@gmail.com> | 2007-02-14 13:37:19 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2007-02-14 13:37:19 +0000 |
commit | 979180ca5f30752d94d64b083b6dbca57dab0c4b (patch) | |
tree | 5566e84f9803ef46fd9a24fb1e451babec53190c /src/compiler/scala/tools/nsc/typechecker/Typers.scala | |
parent | e5b3a8a6b49dd4ab333781e3e7ce595ba14b06eb (diff) | |
download | scala-979180ca5f30752d94d64b083b6dbca57dab0c4b.tar.gz scala-979180ca5f30752d94d64b083b6dbca57dab0c4b.tar.bz2 scala-979180ca5f30752d94d64b083b6dbca57dab0c4b.zip |
more changes to make tuples (...)
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 1e645f3baa..c05c17a0a2 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -545,13 +545,9 @@ trait Typers requires Analyzer { } else if (!meth.isConstructor && mt.paramTypes.isEmpty) { // (4.3) adapt(typed(Apply(tree, List()) setPos tree.pos), mode, pt) } else if (context.implicitsEnabled) { - if (settings.migrate.value && !meth.isConstructor && - isCompatible(tparamsToWildcards(mt, context.undetparams), pt)) - errorTree(tree, migrateMsg + " method can be converted to function only if an expected function type is given"); - else - errorTree(tree, "missing arguments for "+meth+meth.locationString+ - (if (meth.isConstructor) "" - else ";\nprefix this method with `&' if you want to treat it as a partially applied function")) + errorTree(tree, "missing arguments for "+meth+meth.locationString+ + (if (meth.isConstructor) "" + else ";\nprefix this method with `&' if you want to treat it as a partially applied function")) } else { setError(tree) } @@ -1382,8 +1378,14 @@ trait Typers requires Analyzer { case MethodType(formals0, restpe) => val formals = formalTypes(formals0, args.length) var args1 = actualArgs(tree.pos, args, formals.length) - if (formals.length != args1.length) { - Console.println(formals+" "+args1);//DEBUG + if (args1.length != args.length) { + try { + silentTypedApply(tree, fun, args1, mode, pt) + } catch { + case ex: TypeError => + errorTree(tree, "wrong number of arguments for "+treeSymTypeMsg(fun)) + } + } else if (formals.length != args1.length) { errorTree(tree, "wrong number of arguments for "+treeSymTypeMsg(fun)) } else { val tparams = context.undetparams @@ -1537,6 +1539,18 @@ trait Typers requires Analyzer { } } + def silentTypedApply(tree: Tree, fun: Tree, args: List[Tree], mode: int, pt: Type): Tree = + if (context.reportGeneralErrors) { + val context1 = context.makeSilent(context.reportAmbiguousErrors) + context1.undetparams = context.undetparams + val typer1 = newTyper(context1) + val result = typer1.typedApply(tree, fun, args, mode, pt) + context.undetparams = context1.undetparams + result + } else { + typedApply(tree, fun, args, mode, pt) + } + def typedAnnotation(constr: Tree, elements: List[Tree]): AttrInfo = { var attrError: Boolean = false; def error(pos: PositionType, msg: String): Null = { @@ -1643,17 +1657,7 @@ trait Typers requires Analyzer { * @return ... */ def tryTypedApply(fun: Tree, args: List[Tree]): Tree = try { - if (context.reportGeneralErrors) { - val context1 = context.makeSilent(context.reportAmbiguousErrors) - context1.undetparams = context.undetparams - val typer1 = newTyper(context1) - val result = - typer1.typedApply(tree, fun, args, mode, pt) - context.undetparams = context1.undetparams - result - } else { - typedApply(tree, fun, args, mode, pt) - } + silentTypedApply(tree, fun, args, mode, pt) } catch { case ex: CyclicReference => throw ex |