@@ -1620,6 +1620,21 @@ static ConstraintSystem::TypeMatchResult matchCallArguments(
16201620 cs, contextualType, extraArguments,
16211621 cs.getConstraintLocator(locator));
16221622
1623+ for (const auto &extraArg : extraArguments) {
1624+ auto argument = argList->get(extraArg.first);
1625+ auto argType = extraArg.second.getPlainType();
1626+
1627+ // Prevent closure resolution by binding it to a placeholder
1628+ // because the main issue here is invalid overload and
1629+ // errors produced from the closure body are going to be
1630+ // superfluous.
1631+ if (isExpr<ClosureExpr>(argument.getExpr())) {
1632+ cs.recordTypeVariablesAsHoles(argType);
1633+ } else {
1634+ cs.recordAnyTypeVarAsPotentialHole(argType);
1635+ }
1636+ }
1637+
16231638 if (cs.recordFix(fix, /*impact=*/extraArguments.size() * 5))
16241639 return cs.getTypeMatchFailure(locator);
16251640 }
@@ -11371,6 +11386,12 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFallbackTypeConstraint(
1137111386 return SolutionKind::Unsolved;
1137211387 }
1137311388
11389+ // Propagate placeholders into an inferred closure type. Without this
11390+ // we'd produce superfluous diagnostics about parameter/result types.
11391+ if (defaultableType->isPlaceholder() && locator.directlyAt<ClosureExpr>()) {
11392+ recordTypeVariablesAsHoles(fallbackType);
11393+ }
11394+
1137411395 // Otherwise, any type is fine.
1137511396 return SolutionKind::Solved;
1137611397}
0 commit comments