@@ -5994,29 +5994,23 @@ static bool isCastToTypedPointer(ConstraintSystem *CS, const Expr *Fn,
5994
5994
return true ;
5995
5995
}
5996
5996
5997
- static bool diagnoseClosureExplicitParameterMismatch (ConstraintSystem *const CS,
5998
- SourceLoc loc,
5999
- Type paramType,
6000
- Type argType) {
6001
- SmallVector<Identifier, 4 > argLabels;
6002
- gatherArgumentLabels (argType, argLabels);
6003
-
6004
- auto params = decomposeParamType (paramType, nullptr , 0 );
6005
- auto args = decomposeArgType (argType, argLabels);
6006
-
5997
+ static bool diagnoseClosureExplicitParameterMismatch (
5998
+ ConstraintSystem *const CS, SourceLoc loc,
5999
+ ArrayRef<AnyFunctionType::Param> params,
6000
+ ArrayRef<AnyFunctionType::Param> args) {
6007
6001
// We are not trying to diagnose structural problems with top-level
6008
6002
// arguments here.
6009
6003
if (params.size () != args.size ())
6010
6004
return false ;
6011
6005
6012
6006
for (unsigned i = 0 , n = params.size (); i != n; ++i) {
6013
- auto & paramType = params[i].Ty ;
6014
- auto & argType = args[i].Ty ;
6007
+ auto paramType = params[i].getType () ;
6008
+ auto argType = args[i].getType () ;
6015
6009
6016
6010
if (auto paramFnType = paramType->getAs <AnyFunctionType>()) {
6017
6011
if (auto argFnType = argType->getAs <AnyFunctionType>())
6018
6012
return diagnoseClosureExplicitParameterMismatch (
6019
- CS, loc, paramFnType->getInput (), argFnType->getInput ());
6013
+ CS, loc, paramFnType->getParams (), argFnType->getParams ());
6020
6014
}
6021
6015
6022
6016
if (!paramType || !argType || isUnresolvedOrTypeVarType (paramType) ||
@@ -6137,12 +6131,13 @@ bool FailureDiagnosis::diagnoseTrailingClosureErrors(ApplyExpr *callExpr) {
6137
6131
return false ;
6138
6132
}
6139
6133
6140
- if (auto fnType = paramType->getAs <AnyFunctionType>()) {
6141
- if (auto *params = closureExpr->getParameters ()) {
6142
- auto closureParamType = params->getType (CS->getASTContext ());
6143
- if (diagnoseClosureExplicitParameterMismatch (CS, params->getStartLoc (),
6144
- closureParamType,
6145
- fnType->getInput ()))
6134
+ if (auto paramFnType = paramType->getAs <AnyFunctionType>()) {
6135
+ auto closureType = CS->getType (closureExpr);
6136
+ if (auto *argFnType = closureType->getAs <AnyFunctionType>()) {
6137
+ auto *params = closureExpr->getParameters ();
6138
+ auto loc = params ? params->getStartLoc () : closureExpr->getStartLoc ();
6139
+ if (diagnoseClosureExplicitParameterMismatch (
6140
+ CS, loc, argFnType->getParams (), paramFnType->getParams ()))
6146
6141
return true ;
6147
6142
}
6148
6143
}
0 commit comments