[Type checker] Pull the null check into swift::isSIMDOperator().

This commit is contained in:
Doug Gregor
2018-12-11 16:39:10 -08:00
parent 88d34a1c7c
commit 052d4c196c
2 changed files with 5 additions and 5 deletions
+3 -2
View File
@@ -491,6 +491,9 @@ bool DisjunctionStep::shouldStopAt(const DisjunctionChoice &choice) const {
}
bool swift::isSIMDOperator(ValueDecl *value) {
if (!value)
return false;
auto func = dyn_cast<FuncDecl>(value);
if (!func)
return false;
@@ -556,10 +559,8 @@ bool DisjunctionStep::shortCircuitDisjunctionAt(
// If we have an operator from the SIMDOperators module, and the prior
// choice was not from the SIMDOperators module, we're done.
if (currentChoice->getKind() == ConstraintKind::BindOverload &&
currentChoice->getOverloadChoice().isDecl() &&
isSIMDOperator(currentChoice->getOverloadChoice().getDecl()) &&
lastSuccessfulChoice->getKind() == ConstraintKind::BindOverload &&
lastSuccessfulChoice->getOverloadChoice().isDecl() &&
!isSIMDOperator(lastSuccessfulChoice->getOverloadChoice().getDecl()) &&
!ctx.LangOpts.SolverEnableOperatorDesignatedTypes) {
return true;
+2 -3
View File
@@ -1473,7 +1473,7 @@ static ArrayRef<OverloadChoice> partitionSIMDOperators(
// Check whether we have any SIMD operators.
bool foundSIMDOperator = false;
for (const auto &choice : choices) {
if (choice.isDecl() && isSIMDOperator(choice.getDecl())) {
if (isSIMDOperator(choice.getDecl())) {
foundSIMDOperator = true;
break;
}
@@ -1485,8 +1485,7 @@ static ArrayRef<OverloadChoice> partitionSIMDOperators(
scratch.assign(choices.begin(), choices.end());
std::stable_partition(scratch.begin(), scratch.end(),
[](const OverloadChoice &choice) {
return !choice.isDecl() ||
!isSIMDOperator(choice.getDecl());
return !isSIMDOperator(choice.getDecl());
});
return scratch;