@@ -213,14 +213,6 @@ namespace {
213
213
}
214
214
215
215
if (auto *binaryExpr = dyn_cast<BinaryExpr>(expr)) {
216
- if (auto *overload = dyn_cast<OverloadedDeclRefExpr>(binaryExpr->getFn ())) {
217
- // Don't walk into nil coalescing operators. Attempting to favor
218
- // based on operand types is wrong for this operator.
219
- auto identifier = overload->getDecls ().front ()->getBaseIdentifier ();
220
- if (identifier.isNilCoalescingOperator ())
221
- return { false , expr };
222
- }
223
-
224
216
LTI.binaryExprs .push_back (dyn_cast<BinaryExpr>(expr));
225
217
}
226
218
@@ -292,11 +284,25 @@ namespace {
292
284
293
285
// / For a given expression, given information that is global to the
294
286
// / expression, attempt to derive a favored type for it.
295
- bool computeFavoredTypeForExpr (Expr *expr, ConstraintSystem &CS) {
287
+ void computeFavoredTypeForExpr (Expr *expr, ConstraintSystem &CS) {
296
288
LinkedTypeInfo lti;
297
289
298
290
expr->walk (LinkedExprAnalyzer (lti, CS));
299
291
292
+ // Check whether we can proceed with favoring.
293
+ if (llvm::any_of (lti.binaryExprs , [](const BinaryExpr *op) {
294
+ auto *ODRE = dyn_cast<OverloadedDeclRefExpr>(op->getFn ());
295
+ if (!ODRE)
296
+ return false ;
297
+
298
+ // Attempting to favor based on operand types is wrong for
299
+ // nil-coalescing operator.
300
+ auto identifier = ODRE->getDecls ().front ()->getBaseIdentifier ();
301
+ return identifier.isNilCoalescingOperator ();
302
+ })) {
303
+ return ;
304
+ }
305
+
300
306
if (lti.collectedTypes .size () == 1 ) {
301
307
// TODO: Compute the BCT.
302
308
@@ -371,13 +377,9 @@ namespace {
371
377
};
372
378
373
379
simplifyBinOpExprTyVars ();
374
-
375
- return true ;
376
380
}
377
-
378
- return false ;
379
381
}
380
-
382
+
381
383
// / Determine whether the given parameter type and argument should be
382
384
// / "favored" because they match exactly.
383
385
bool isFavoredParamAndArg (ConstraintSystem &CS, Type paramTy, Type argTy,
0 commit comments