@@ -1537,9 +1537,8 @@ bool TypeChecker::coercePatternToType(Pattern *&P, DeclContext *dc, Type type,
15371537// / TODO: These diagnostics should be a lot better now that we know this is
15381538// / all specific to closures.
15391539// /
1540- bool TypeChecker::coerceParameterListToType (ParameterList *P, ClosureExpr *CE,
1541- AnyFunctionType *FN) {
1542- Type paramListType = FN->getInput ();
1540+ bool TypeChecker::coerceParameterListToType (ParameterList *P, DeclContext *DC,
1541+ Type paramListType) {
15431542 bool hadError = paramListType->is <ErrorType>();
15441543
15451544 // Sometimes a scalar type gets applied to a single-argument parameter list.
@@ -1548,7 +1547,7 @@ bool TypeChecker::coerceParameterListToType(ParameterList *P, ClosureExpr *CE,
15481547
15491548 // Check that the type, if explicitly spelled, is ok.
15501549 if (param->getTypeLoc ().getTypeRepr ()) {
1551- hadError |= validateParameterType (param, CE , TypeResolutionOptions (),
1550+ hadError |= validateParameterType (param, DC , TypeResolutionOptions (),
15521551 nullptr , *this );
15531552
15541553 // Now that we've type checked the explicit argument type, see if it
@@ -1590,10 +1589,11 @@ bool TypeChecker::coerceParameterListToType(ParameterList *P, ClosureExpr *CE,
15901589 // The number of elements must match exactly.
15911590 // TODO: incomplete tuple patterns, with some syntax.
15921591 if (!hadError && tupleTy->getNumElements () != P->size ()) {
1593- auto fnType = FunctionType::get (paramListType->getDesugaredType (),
1594- FN->getResult ());
1595- diagnose (P->getStartLoc (), diag::closure_argument_list_tuple,
1596- fnType, tupleTy->getNumElements (), P->size ());
1592+ if (P->size () == 1 )
1593+ return handleParameter (P->get (0 ), paramListType);
1594+
1595+ diagnose (P->getStartLoc (), diag::tuple_pattern_length_mismatch,
1596+ paramListType);
15971597 hadError = true ;
15981598 }
15991599
0 commit comments