@@ -1620,6 +1620,21 @@ static ConstraintSystem::TypeMatchResult matchCallArguments(
1620
1620
cs, contextualType, extraArguments,
1621
1621
cs.getConstraintLocator(locator));
1622
1622
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
+
1623
1638
if (cs.recordFix(fix, /*impact=*/extraArguments.size() * 5))
1624
1639
return cs.getTypeMatchFailure(locator);
1625
1640
}
@@ -11371,6 +11386,12 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFallbackTypeConstraint(
11371
11386
return SolutionKind::Unsolved;
11372
11387
}
11373
11388
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
+
11374
11395
// Otherwise, any type is fine.
11375
11396
return SolutionKind::Solved;
11376
11397
}
0 commit comments