@@ -195,12 +195,6 @@ class FailureDiagnosis :public ASTVisitor<FailureDiagnosis, /*exprresult*/bool>{
195
195
// / Emit an ambiguity diagnostic about the specified expression.
196
196
void diagnoseAmbiguity (Expr *E);
197
197
198
- // / Attempt to produce a diagnostic for a mismatch between an expression's
199
- // / type and its assumed contextual type.
200
- bool diagnoseContextualConversionError (Expr *expr, Type contextualType,
201
- ContextualTypePurpose CTP,
202
- Type suggestedType = Type());
203
-
204
198
private:
205
199
// / Validate potential contextual type for type-checking one of the
206
200
// / sub-expressions, usually correct/valid types are the ones which
@@ -500,51 +494,6 @@ DeclContext *FailureDiagnosis::findDeclContext(Expr *subExpr) const {
500
494
return finder.DC ;
501
495
}
502
496
503
- bool FailureDiagnosis::diagnoseContextualConversionError (
504
- Expr *expr, Type contextualType, ContextualTypePurpose CTP,
505
- Type suggestedType) {
506
- // If the constraint system has a contextual type, then we can test to see if
507
- // this is the problem that prevents us from solving the system.
508
- if (!contextualType)
509
- return false ;
510
-
511
- // Try re-type-checking the expression without the contextual type to see if
512
- // it can work without it. If so, the contextual type is the problem. We
513
- // force a recheck, because "expr" is likely in our table with the extra
514
- // contextual constraint that we know we are relaxing.
515
- TCCOptions options = TCC_ForceRecheck;
516
- if (contextualType->is <InOutType>())
517
- options |= TCC_AllowLValue;
518
-
519
- auto *recheckedExpr = typeCheckChildIndependently (expr, options);
520
- auto exprType = recheckedExpr ? CS.getType (recheckedExpr) : Type ();
521
-
522
- // If there is a suggested type and re-typecheck failed, let's use it.
523
- if (!exprType)
524
- exprType = suggestedType;
525
-
526
- // If it failed and diagnosed something, then we're done.
527
- if (!exprType)
528
- return CS.getASTContext ().Diags .hadAnyError ();
529
-
530
- // If we don't have a type for the expression, then we cannot use it in
531
- // conversion constraint diagnostic generation. If the types match, then it
532
- // must not be the contextual type that is the problem.
533
- if (isUnresolvedOrTypeVarType (exprType) || exprType->isEqual (contextualType))
534
- return false ;
535
-
536
- // Don't attempt fixits if we have an unsolved type variable, since
537
- // the recovery path's recursion into the type checker via typeCheckCast()
538
- // will confuse matters.
539
- if (exprType->hasTypeVariable ())
540
- return false ;
541
-
542
- ContextualFailure failure (
543
- CS, CTP, exprType, contextualType,
544
- CS.getConstraintLocator (expr, LocatorPathElt::ContextualType ()));
545
- return failure.diagnoseAsError ();
546
- }
547
-
548
497
// ===----------------------------------------------------------------------===//
549
498
// Diagnose assigning variable to itself.
550
499
// ===----------------------------------------------------------------------===//
@@ -1256,13 +1205,6 @@ void ConstraintSystem::diagnoseFailureFor(SolutionApplicationTarget target) {
1256
1205
if (diagnosis.diagnoseExprFailure ())
1257
1206
return ;
1258
1207
1259
- // If this is a contextual conversion problem, dig out some information.
1260
- if (diagnosis.diagnoseContextualConversionError (
1261
- expr,
1262
- getContextualType (expr),
1263
- getContextualTypePurpose (expr)))
1264
- return ;
1265
-
1266
1208
// If no one could find a problem with this expression or constraint system,
1267
1209
// then it must be well-formed... but is ambiguous. Handle this by diagnostic
1268
1210
// various cases that come up.
0 commit comments