@@ -866,7 +866,7 @@ Type PatternTypeRequest::evaluate(Evaluator &evaluator,
866866 // If we're type checking this pattern in a context that can provide type
867867 // information, then the lack of type information is not an error.
868868 if (options & TypeResolutionFlags::AllowUnspecifiedTypes)
869- return Context. TheUnresolvedType ;
869+ return PlaceholderType::get ( Context, P) ;
870870
871871 Context.Diags .diagnose (P->getLoc (), diag::cannot_infer_type_for_pattern);
872872 if (auto named = dyn_cast<NamedPattern>(P)) {
@@ -946,7 +946,7 @@ Type PatternTypeRequest::evaluate(Evaluator &evaluator,
946946 return ErrorType::get (Context);
947947 }
948948
949- return Context. TheUnresolvedType ;
949+ return PlaceholderType::get ( Context, P) ;
950950 }
951951 llvm_unreachable (" bad pattern kind!" );
952952}
@@ -1736,41 +1736,18 @@ Pattern *TypeChecker::coercePatternToType(
17361736// / contextual type.
17371737void TypeChecker::coerceParameterListToType (ParameterList *P,
17381738 AnyFunctionType *FN) {
1739-
1740- // Local function to check if the given type is valid e.g. doesn't have
1741- // errors, type variables or unresolved types related to it.
1742- auto isValidType = [](Type type) -> bool {
1743- return !(type->hasError () || type->hasUnresolvedType ());
1744- };
1745-
1746- // Local function to check whether type of given parameter
1747- // should be coerced to a given contextual type or not.
1748- auto shouldOverwriteParam = [&](ParamDecl *param) -> bool {
1749- return !isValidType (param->getTypeInContext ());
1750- };
1751-
1752- auto handleParameter = [&](ParamDecl *param, Type ty, bool forceMutable) {
1753- if (forceMutable)
1754- param->setSpecifier (ParamDecl::Specifier::InOut);
1755-
1756- // If contextual type is invalid and we have a valid argument type
1757- // trying to coerce argument to contextual type would mean erasing
1758- // valuable diagnostic information.
1759- if (isValidType (ty) || shouldOverwriteParam (param)) {
1760- param->setInterfaceType (ty->mapTypeOutOfContext ());
1761- }
1762- };
1763-
17641739 // Coerce each parameter to the respective type.
17651740 ArrayRef<AnyFunctionType::Param> params = FN->getParams ();
17661741 for (unsigned i = 0 , e = P->size (); i != e; ++i) {
17671742 auto ¶m = P->get (i);
17681743 assert (param->getArgumentName ().empty () &&
17691744 " Closures cannot have API names" );
1770-
1771- handleParameter (param,
1772- params[i].getParameterType (),
1773- params[i].isInOut ());
17741745 assert (!param->isDefaultArgument () && " Closures cannot have default args" );
1746+
1747+ if (params[i].isInOut ())
1748+ param->setSpecifier (ParamDecl::Specifier::InOut);
1749+
1750+ param->setInterfaceType (
1751+ params[i].getParameterType ()->mapTypeOutOfContext ());
17751752 }
17761753}
0 commit comments