@@ -3243,35 +3243,6 @@ bool FailureDiagnosis::diagnoseClosureExpr(
3243
3243
return true ;
3244
3244
}
3245
3245
3246
- // If the body of the closure looked ok, then look for a contextual type
3247
- // error. This is necessary because FailureDiagnosis::diagnoseExprFailure
3248
- // doesn't do this for closures.
3249
- if (contextualType) {
3250
- auto fnType = contextualType->getAs <AnyFunctionType>();
3251
- if (!fnType || fnType->isEqual (CS.getType (CE)))
3252
- return false ;
3253
-
3254
- auto contextualResultType = fnType->getResult ();
3255
- // If the result type was unknown, it doesn't really make
3256
- // sense to diagnose from expected to unknown here.
3257
- if (isInvalidClosureResultType (contextualResultType))
3258
- return false ;
3259
-
3260
- // If the closure had an explicitly written return type incompatible with
3261
- // the contextual type, diagnose that.
3262
- if (CE->hasExplicitResultType () &&
3263
- CE->getExplicitResultTypeLoc ().getTypeRepr ()) {
3264
- auto explicitResultTy = CE->getExplicitResultTypeLoc ().getType ();
3265
- if (fnType && !explicitResultTy->isEqual (contextualResultType)) {
3266
- auto repr = CE->getExplicitResultTypeLoc ().getTypeRepr ();
3267
- diagnose (repr->getStartLoc (), diag::incorrect_explicit_closure_result,
3268
- explicitResultTy, fnType->getResult ())
3269
- .fixItReplace (repr->getSourceRange (),fnType->getResult ().getString ());
3270
- return true ;
3271
- }
3272
- }
3273
- }
3274
-
3275
3246
// Otherwise, we can't produce a specific diagnostic.
3276
3247
return false ;
3277
3248
}
0 commit comments