Skip to content

Commit 052d4c1

Browse files
committed
[Type checker] Pull the null check into swift::isSIMDOperator().
1 parent 88d34a1 commit 052d4c1

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/Sema/CSStep.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,9 @@ bool DisjunctionStep::shouldStopAt(const DisjunctionChoice &choice) const {
491491
}
492492

493493
bool swift::isSIMDOperator(ValueDecl *value) {
494+
if (!value)
495+
return false;
496+
494497
auto func = dyn_cast<FuncDecl>(value);
495498
if (!func)
496499
return false;
@@ -556,10 +559,8 @@ bool DisjunctionStep::shortCircuitDisjunctionAt(
556559
// If we have an operator from the SIMDOperators module, and the prior
557560
// choice was not from the SIMDOperators module, we're done.
558561
if (currentChoice->getKind() == ConstraintKind::BindOverload &&
559-
currentChoice->getOverloadChoice().isDecl() &&
560562
isSIMDOperator(currentChoice->getOverloadChoice().getDecl()) &&
561563
lastSuccessfulChoice->getKind() == ConstraintKind::BindOverload &&
562-
lastSuccessfulChoice->getOverloadChoice().isDecl() &&
563564
!isSIMDOperator(lastSuccessfulChoice->getOverloadChoice().getDecl()) &&
564565
!ctx.LangOpts.SolverEnableOperatorDesignatedTypes) {
565566
return true;

lib/Sema/ConstraintSystem.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ static ArrayRef<OverloadChoice> partitionSIMDOperators(
14731473
// Check whether we have any SIMD operators.
14741474
bool foundSIMDOperator = false;
14751475
for (const auto &choice : choices) {
1476-
if (choice.isDecl() && isSIMDOperator(choice.getDecl())) {
1476+
if (isSIMDOperator(choice.getDecl())) {
14771477
foundSIMDOperator = true;
14781478
break;
14791479
}
@@ -1485,8 +1485,7 @@ static ArrayRef<OverloadChoice> partitionSIMDOperators(
14851485
scratch.assign(choices.begin(), choices.end());
14861486
std::stable_partition(scratch.begin(), scratch.end(),
14871487
[](const OverloadChoice &choice) {
1488-
return !choice.isDecl() ||
1489-
!isSIMDOperator(choice.getDecl());
1488+
return !isSIMDOperator(choice.getDecl());
14901489
});
14911490

14921491
return scratch;

0 commit comments

Comments
 (0)