Skip to content

Commit 471af31

Browse files
authored
Merge pull request #17751 from xedin/cleanup-after-simplify
[SpaceEngine] NFC: Remove convenience `intersect` because `simplify` …
2 parents 6b41eb6 + f5a7d3f commit 471af31

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

lib/Sema/TypeCheckSwitchStmt.cpp

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -502,13 +502,6 @@ namespace {
502502
}
503503
}
504504

505-
/// Convenience declaration to make the intersection operation look more
506-
/// symmetric.
507-
static Space intersect(const Space &a, const Space &b, TypeChecker &TC,
508-
const DeclContext *DC) {
509-
return a.intersect(b, TC, DC);
510-
}
511-
512505
// Returns the intersection of this space with another. The intersection
513506
// is the largest shared subspace occupied by both arguments.
514507
Space intersect(const Space &other, TypeChecker &TC,
@@ -530,7 +523,7 @@ namespace {
530523
std::transform(
531524
other.getSpaces().begin(), other.getSpaces().end(),
532525
std::back_inserter(intersectedCases),
533-
[&](const Space &s) { return intersect(*this, s, TC, DC); });
526+
[&](const Space &s) { return this->intersect(s, TC, DC); });
534527
return Space::forDisjunct(intersectedCases);
535528
}
536529

@@ -540,26 +533,26 @@ namespace {
540533
PAIRCASE (SpaceKind::Disjunct, SpaceKind::BooleanConstant):
541534
PAIRCASE (SpaceKind::Disjunct, SpaceKind::UnknownCase): {
542535
// (S1 || ... || Sn) & S iff (S & S1) && ... && (S & Sn)
543-
return intersect(other, *this, TC, DC);
536+
return other.intersect(*this, TC, DC);
544537
}
545538
PAIRCASE (SpaceKind::Type, SpaceKind::Type): {
546539
// Optimization: The intersection of equal types is that type.
547540
if (this->getType()->isEqual(other.getType())) {
548541
return other;
549542
} else if (canDecompose(this->getType(), DC)) {
550543
auto decomposition = decompose(TC, DC, this->getType());
551-
return intersect(decomposition, other, TC, DC);
544+
return decomposition.intersect(other, TC, DC);
552545
} else if (canDecompose(other.getType(), DC)) {
553546
auto decomposition = decompose(TC, DC, other.getType());
554-
return intersect(*this, decomposition, TC, DC);
547+
return this->intersect(decomposition, TC, DC);
555548
} else {
556549
return other;
557550
}
558551
}
559552
PAIRCASE (SpaceKind::Type, SpaceKind::Constructor): {
560553
if (canDecompose(this->getType(), DC)) {
561554
auto decomposition = decompose(TC, DC, this->getType());
562-
return intersect(decomposition, other, TC, DC);
555+
return decomposition.intersect(other, TC, DC);
563556
} else {
564557
return other;
565558
}
@@ -580,7 +573,7 @@ namespace {
580573
std::transform(this->getSpaces().begin(), this->getSpaces().end(),
581574
std::back_inserter(newSubSpaces),
582575
[&](const Space &subSpace) {
583-
return intersect(subSpace, other, TC, DC);
576+
return subSpace.intersect(other, TC, DC);
584577
});
585578
return Space::forConstructor(this->getType(), this->getHead(),
586579
this->canDowngradeToWarning(),
@@ -605,7 +598,7 @@ namespace {
605598
auto j = other.getSpaces().begin();
606599
for (; i != this->getSpaces().end() && j != other.getSpaces().end();
607600
++i, ++j) {
608-
auto result = intersect(*i, *j, TC, DC);
601+
auto result = i->intersect(*j, TC, DC);
609602
// If at least one of the constructor sub-spaces is empty,
610603
// it makes the whole space empty as well.
611604
if (result.isEmpty()) {
@@ -619,7 +612,7 @@ namespace {
619612

620613
PAIRCASE (SpaceKind::UnknownCase, SpaceKind::Type):
621614
PAIRCASE (SpaceKind::UnknownCase, SpaceKind::Constructor):
622-
return intersect(other, *this, TC, DC);
615+
return other.intersect(*this, TC, DC);
623616
PAIRCASE (SpaceKind::UnknownCase, SpaceKind::UnknownCase):
624617
if (other.isAllowedButNotRequired())
625618
return other;
@@ -635,7 +628,7 @@ namespace {
635628

636629
if (canDecompose(other.getType(), DC)) {
637630
auto decomposition = decompose(TC, DC, other.getType());
638-
return intersect(*this, decomposition, TC, DC);
631+
return this->intersect(decomposition, TC, DC);
639632
}
640633
return Space();
641634
}
@@ -645,7 +638,7 @@ namespace {
645638
return Space();
646639

647640
PAIRCASE (SpaceKind::Type, SpaceKind::BooleanConstant): {
648-
return intersect(other, *this, TC, DC);
641+
return other.intersect(*this, TC, DC);
649642
}
650643

651644
PAIRCASE (SpaceKind::Empty, SpaceKind::BooleanConstant):
@@ -689,10 +682,10 @@ namespace {
689682
return Space();
690683
} else if (canDecompose(this->getType(), DC)) {
691684
auto decomposition = decompose(TC, DC, this->getType());
692-
return intersect(decomposition, other, TC, DC);
685+
return decomposition.intersect(other, TC, DC);
693686
} else if (canDecompose(other.getType(), DC)) {
694687
auto decomposition = decompose(TC, DC, other.getType());
695-
return intersect(*this, decomposition, TC, DC);
688+
return this->intersect(decomposition, TC, DC);
696689
}
697690
return Space();
698691
}
@@ -783,7 +776,7 @@ namespace {
783776
auto &s2 = *j;
784777
// If the intersection of each subspace is ever empty then the
785778
// two spaces are disjoint and their difference is the first space.
786-
if (intersect(s1, s2, TC, DC).isEmpty()) {
779+
if (s1.intersect(s2, TC, DC).isEmpty()) {
787780
return *this;
788781
}
789782

0 commit comments

Comments
 (0)