Skip to content

Commit df4ae0a

Browse files
committed
[CSOptimizer] Update candidate selection to use arithmetic operator chain inference
1 parent 4eec3f6 commit df4ae0a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/Sema/CSOptimizer.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,8 @@ static void determineBestChoicesInContext(
701701
llvm::TinyPtrVector<Type> resultTypes;
702702

703703
bool hasArgumentCandidates = false;
704+
bool isOperator = isOperatorDisjunction(disjunction);
705+
704706
for (unsigned i = 0, n = argFuncType->getNumParams(); i != n; ++i) {
705707
const auto &param = argFuncType->getParams()[i];
706708
auto argType = cs.simplifyType(param.getPlainType());
@@ -759,6 +761,17 @@ static void determineBestChoicesInContext(
759761
// a type for the second operand of `+` based on a type being
760762
// constructed.
761763
if (typeVar->getImpl().isFunctionResult()) {
764+
auto *resultLoc = typeVar->getImpl().getLocator();
765+
766+
// We don't want to try and infer parts of operator
767+
// chains.
768+
if (!isOperator) {
769+
if (auto type = inferTypeOfArithmeticOperatorChain(
770+
cs.DC, resultLoc->getAnchor())) {
771+
types.push_back({type, /*fromLiteral=*/true});
772+
}
773+
}
774+
762775
auto binding =
763776
inferTypeFromInitializerResultType(cs, typeVar, disjunctions);
764777

0 commit comments

Comments
 (0)