File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -493,6 +493,24 @@ static void determineBestChoicesInContext(
493
493
}
494
494
495
495
if (score > 0 ) {
496
+ if (decl->isOperator () &&
497
+ decl->getBaseIdentifier ().isArithmeticOperator () &&
498
+ overloadType->getNumParams () == 2 ) {
499
+ // Nudge the score slightly to prefer concrete homogeneous
500
+ // operators.
501
+ //
502
+ // This is an opportunistic optimization based on the operator
503
+ // use patterns where homogeneous operators are the most
504
+ // heavily used ones.
505
+ auto resultTy = overloadType->getResult ();
506
+ if (!resultTy->hasTypeParameter () &&
507
+ llvm::all_of (overloadType->getParams (),
508
+ [&resultTy](const auto ¶m) {
509
+ return param.getPlainType ()->isEqual (resultTy);
510
+ }))
511
+ score += 0.001 ;
512
+ }
513
+
496
514
favoredChoices.push_back ({choice, score});
497
515
bestScore = std::max (bestScore, score);
498
516
}
You can’t perform that action at this time.
0 commit comments