Skip to content

Commit 4900abc

Browse files
committed
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.
1 parent 9b2d9b2 commit 4900abc

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -541,27 +541,27 @@ trait Applications extends Compatibility { self: Typer =>
541541
// a modified tree but this would be more convoluted and less efficient.
542542
if (proto.isTupled) proto = proto.tupled
543543

544-
methPart(fun1).tpe match {
545-
case funRef: TermRef =>
546-
tryEither { implicit ctx =>
547-
val app =
548-
if (proto.argsAreTyped) new ApplyToTyped(tree, fun1, funRef, proto.typedArgs, pt)
549-
else new ApplyToUntyped(tree, fun1, funRef, proto, pt)(argCtx)
550-
val result = app.result
551-
convertNewArray(ConstFold(result))
552-
} { (failedVal, failedState) =>
553-
val fun2 = tryInsertImplicitOnQualifier(fun1, proto)
554-
if (fun1 eq fun2) {
555-
failedState.commit()
556-
failedVal
557-
} else typedApply(
558-
cpy.Apply(tree)(untpd.TypedSplice(fun2), proto.typedArgs map untpd.TypedSplice), pt)
559-
}
560-
case _ =>
561-
fun1.tpe match {
562-
case ErrorType => tree.withType(ErrorType)
563-
case tp => handleUnexpectedFunType(tree, fun1)
564-
}
544+
fun1.tpe match {
545+
case ErrorType => tree.withType(ErrorType)
546+
case _ => methPart(fun1).tpe match {
547+
case funRef: TermRef =>
548+
tryEither { implicit ctx =>
549+
val app =
550+
if (proto.argsAreTyped) new ApplyToTyped(tree, fun1, funRef, proto.typedArgs, pt)
551+
else new ApplyToUntyped(tree, fun1, funRef, proto, pt)(argCtx)
552+
val result = app.result
553+
convertNewArray(ConstFold(result))
554+
} { (failedVal, failedState) =>
555+
val fun2 = tryInsertImplicitOnQualifier(fun1, proto)
556+
if (fun1 eq fun2) {
557+
failedState.commit()
558+
failedVal
559+
} else typedApply(
560+
cpy.Apply(tree)(untpd.TypedSplice(fun2), proto.typedArgs map untpd.TypedSplice), pt)
561+
}
562+
case _ =>
563+
handleUnexpectedFunType(tree, fun1)
564+
}
565565
}
566566
}
567567

0 commit comments

Comments
 (0)