From 41e7d9d46177650d23447f99989e8347aca56e71 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 27 Oct 2013 18:11:14 +0100 Subject: Fixing `apply` insertion. Previously we encountered failures with polymorphic applies and infinite recursion in case of errors. The commit contains fixes for both problems. --- src/dotty/tools/dotc/typer/Typer.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/dotty/tools/dotc/typer/Typer.scala') diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 1bdc5516c..c6d419675 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -920,7 +920,9 @@ class Typer extends Namer with Applications with Implicits { def tryInsertApply(tree: Tree, pt: Type)(fallBack: StateFul[Tree] => Tree)(implicit ctx: Context): Tree = tryEither { - implicit ctx => typedSelect(untpd.Select(untpd.TypedSplice(tree), nme.apply), pt) + implicit ctx => + val sel = typedSelect(untpd.Select(untpd.TypedSplice(tree), nme.apply), pt) + if (sel.tpe.isError) sel else adapt(sel, pt) } { fallBack } @@ -1008,7 +1010,7 @@ class Typer extends Namer with Applications with Implicits { } def adaptToArgs(wtp: Type, pt: FunProto) = wtp match { - case _: MethodType => tree + case _: MethodType | _: PolyType => tree case _ => tryInsertApply(tree, pt) { val more = tree match { case Apply(_, _) => " more" @@ -1086,6 +1088,8 @@ class Typer extends Namer with Applications with Implicits { tree match { case _: MemberDef | _: PackageDef | _: Import | _: WithoutType[_] => tree case _ => tree.tpe.widen match { + case ErrorType => + tree case ref: TermRef => adaptOverloaded(ref) case poly: PolyType => -- cgit v1.2.3