From 4900abc7edcd209608cf7539a968cb375bdcb9c1 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 8 Dec 2015 18:10:07 +0100 Subject: Avoid unassigned type errors when typing curried functions. If a partial application of a function has an error type, make sure the whole tree also has an error type. Before, sometimes the type was missing which led to a partial application error. --- src/dotty/tools/dotc/typer/Applications.scala | 42 +++++++++++++-------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala index 941b35d71..8370b3059 100644 --- a/src/dotty/tools/dotc/typer/Applications.scala +++ b/src/dotty/tools/dotc/typer/Applications.scala @@ -541,27 +541,27 @@ trait Applications extends Compatibility { self: Typer => // a modified tree but this would be more convoluted and less efficient. if (proto.isTupled) proto = proto.tupled - methPart(fun1).tpe match { - case funRef: TermRef => - tryEither { implicit ctx => - val app = - if (proto.argsAreTyped) new ApplyToTyped(tree, fun1, funRef, proto.typedArgs, pt) - else new ApplyToUntyped(tree, fun1, funRef, proto, pt)(argCtx) - val result = app.result - convertNewArray(ConstFold(result)) - } { (failedVal, failedState) => - val fun2 = tryInsertImplicitOnQualifier(fun1, proto) - if (fun1 eq fun2) { - failedState.commit() - failedVal - } else typedApply( - cpy.Apply(tree)(untpd.TypedSplice(fun2), proto.typedArgs map untpd.TypedSplice), pt) - } - case _ => - fun1.tpe match { - case ErrorType => tree.withType(ErrorType) - case tp => handleUnexpectedFunType(tree, fun1) - } + fun1.tpe match { + case ErrorType => tree.withType(ErrorType) + case _ => methPart(fun1).tpe match { + case funRef: TermRef => + tryEither { implicit ctx => + val app = + if (proto.argsAreTyped) new ApplyToTyped(tree, fun1, funRef, proto.typedArgs, pt) + else new ApplyToUntyped(tree, fun1, funRef, proto, pt)(argCtx) + val result = app.result + convertNewArray(ConstFold(result)) + } { (failedVal, failedState) => + val fun2 = tryInsertImplicitOnQualifier(fun1, proto) + if (fun1 eq fun2) { + failedState.commit() + failedVal + } else typedApply( + cpy.Apply(tree)(untpd.TypedSplice(fun2), proto.typedArgs map untpd.TypedSplice), pt) + } + case _ => + handleUnexpectedFunType(tree, fun1) + } } } -- cgit v1.2.3