@@ -4340,8 +4340,34 @@ bool ConstraintSystem::repairFailures(
4340
4340
// as a narrow exception to SE-0110, see `matchFunctionTypes`.
4341
4341
//
4342
4342
// But if `T.Element` didn't get resolved to `Void` we'd like
4343
- // to diagnose this as a missing argument which can't be ignored.
4343
+ // to diagnose this as a missing argument which can't be ignored or
4344
+ // a tuple is trying to be inferred as a tuple for destructuring but
4345
+ // contextual argument does not match(in this case we remove the extra
4346
+ // closure arguments).
4344
4347
if (arg != getTypeVariables ().end ()) {
4348
+ if (auto argToParamElt =
4349
+ path.back ().getAs <LocatorPathElt::ApplyArgToParam>()) {
4350
+ auto loc = getConstraintLocator (anchor, path);
4351
+ auto closureAnchor =
4352
+ getAsExpr<ClosureExpr>(simplifyLocatorToAnchor (loc));
4353
+ if (rhs->is <TupleType>() && closureAnchor &&
4354
+ closureAnchor->getParameters ()->size () > 1 ) {
4355
+ auto callee = getCalleeLocator (loc);
4356
+ auto overload = findSelectedOverloadFor (callee);
4357
+ if (overload) {
4358
+ auto fnType = overload->openedType ->getAs <FunctionType>();
4359
+ auto paramIdx = argToParamElt->getParamIdx ();
4360
+ if (auto paramType = fnType->getParams ()[paramIdx]
4361
+ .getOldType ()
4362
+ ->getAs <FunctionType>()) {
4363
+ conversionsOrFixes.push_back (
4364
+ RemoveExtraneousArguments::create (*this , paramType, {}, loc));
4365
+ break ;
4366
+ }
4367
+ }
4368
+ }
4369
+ }
4370
+
4345
4371
conversionsOrFixes.push_back (AddMissingArguments::create (
4346
4372
*this , {SynthesizedArg{0 , AnyFunctionType::Param (*arg)}},
4347
4373
getConstraintLocator (anchor, path)));
@@ -11216,7 +11242,8 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
11216
11242
case FixKind::AllowCheckedCastCoercibleOptionalType:
11217
11243
case FixKind::AllowUnsupportedRuntimeCheckedCast:
11218
11244
case FixKind::AllowAlwaysSucceedCheckedCast:
11219
- case FixKind::AllowInvalidStaticMemberRefOnProtocolMetatype: {
11245
+ case FixKind::AllowInvalidStaticMemberRefOnProtocolMetatype:
11246
+ case FixKind::RemoveExtraneousArguments: {
11220
11247
return recordFix (fix) ? SolutionKind::Error : SolutionKind::Solved;
11221
11248
}
11222
11249
@@ -11365,7 +11392,6 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
11365
11392
case FixKind::AllowTypeOrInstanceMember:
11366
11393
case FixKind::AllowInvalidPartialApplication:
11367
11394
case FixKind::AllowInvalidInitRef:
11368
- case FixKind::RemoveExtraneousArguments:
11369
11395
case FixKind::AllowClosureParameterDestructuring:
11370
11396
case FixKind::AllowInaccessibleMember:
11371
11397
case FixKind::AllowAnyObjectKeyPathRoot:
0 commit comments