aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Typer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-08-22 14:24:49 +0200
committerMartin Odersky <odersky@gmail.com>2013-08-22 14:24:49 +0200
commit749934aeafecc65c865d92056467c08540add8cc (patch)
tree7b20ad103b0acb5b08f96c146a5a8c217a8e4b82 /src/dotty/tools/dotc/typer/Typer.scala
parentcbcdbd6fb8c0bf372a61b4ddd5b6ce181964776d (diff)
downloaddotty-749934aeafecc65c865d92056467c08540add8cc.tar.gz
dotty-749934aeafecc65c865d92056467c08540add8cc.tar.bz2
dotty-749934aeafecc65c865d92056467c08540add8cc.zip
More typer bug fixes and improvements in error messages
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 82b2e25b6..c693209f4 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -930,6 +930,8 @@ class Typer extends Namer with Applications with Implicits {
*/
def adapt(tree: Tree, pt: Type)(implicit ctx: Context): Tree = ctx.traceIndented(i"adapting $tree of type ${tree.tpe} to $pt", show = false) {
+ def methodStr = err.refStr(methPart(tree).tpe)
+
def adaptOverloaded(ref: TermRef) = {
val altDenots = ref.denot.alternatives
val alts = altDenots map (alt =>
@@ -957,12 +959,11 @@ class Typer extends Namer with Applications with Implicits {
def adaptToArgs(tp: Type, pt: FunProto) = tp match {
case _: MethodType => tree
case _ => tryInsertApply(tree, pt) {
- def fn = err.refStr(methPart(tree).tpe)
val more = tree match {
case Apply(_, _) => " more"
case _ => ""
}
- _ => errorTree(tree, i"$fn does not take$more parameters")
+ _ => errorTree(tree, i"$methodStr does not take$more parameters")
}
}
@@ -970,7 +971,12 @@ class Typer extends Namer with Applications with Implicits {
case tp: ExprType =>
adapt(tree.withType(tp.resultType), pt)
case tp: ImplicitMethodType =>
- val args = tp.paramTypes map (inferImplicit(_, EmptyTree, tree.pos))
+ val args = (tp.paramNames, tp.paramTypes).zipped map { (pname, formal) =>
+ val arg = inferImplicit(formal, EmptyTree, tree.pos.endPos)
+ if (arg.isEmpty)
+ ctx.error(i"no implicit argument of type $formal found for parameter $pname of $methodStr", tree.pos.endPos)
+ arg
+ }
adapt(tpd.Apply(tree, args), pt)
case tp: MethodType =>
if (defn.isFunctionType(pt) && !tree.symbol.isConstructor)
@@ -979,7 +985,7 @@ class Typer extends Namer with Applications with Implicits {
adapt(tpd.Apply(tree, Nil), pt)
else
errorTree(tree,
- i"""missing arguments for ${tree.symbol}
+ i"""missing arguments for $methodStr
|follow this method with `_' if you want to treat it as a partially applied function""".stripMargin)
case _ =>
if (tp <:< pt) tree