@@ -502,13 +502,6 @@ namespace {
502
502
}
503
503
}
504
504
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
-
512
505
// Returns the intersection of this space with another. The intersection
513
506
// is the largest shared subspace occupied by both arguments.
514
507
Space intersect (const Space &other, TypeChecker &TC,
@@ -530,7 +523,7 @@ namespace {
530
523
std::transform (
531
524
other.getSpaces ().begin (), other.getSpaces ().end (),
532
525
std::back_inserter (intersectedCases),
533
- [&](const Space &s) { return intersect (* this , s, TC, DC); });
526
+ [&](const Space &s) { return this -> intersect (s, TC, DC); });
534
527
return Space::forDisjunct (intersectedCases);
535
528
}
536
529
@@ -540,26 +533,26 @@ namespace {
540
533
PAIRCASE (SpaceKind::Disjunct, SpaceKind::BooleanConstant):
541
534
PAIRCASE (SpaceKind::Disjunct, SpaceKind::UnknownCase): {
542
535
// (S1 || ... || Sn) & S iff (S & S1) && ... && (S & Sn)
543
- return intersect (other, *this , TC, DC);
536
+ return other. intersect (*this , TC, DC);
544
537
}
545
538
PAIRCASE (SpaceKind::Type, SpaceKind::Type): {
546
539
// Optimization: The intersection of equal types is that type.
547
540
if (this ->getType ()->isEqual (other.getType ())) {
548
541
return other;
549
542
} else if (canDecompose (this ->getType (), DC)) {
550
543
auto decomposition = decompose (TC, DC, this ->getType ());
551
- return intersect (decomposition, other, TC, DC);
544
+ return decomposition. intersect (other, TC, DC);
552
545
} else if (canDecompose (other.getType (), DC)) {
553
546
auto decomposition = decompose (TC, DC, other.getType ());
554
- return intersect (* this , decomposition, TC, DC);
547
+ return this -> intersect (decomposition, TC, DC);
555
548
} else {
556
549
return other;
557
550
}
558
551
}
559
552
PAIRCASE (SpaceKind::Type, SpaceKind::Constructor): {
560
553
if (canDecompose (this ->getType (), DC)) {
561
554
auto decomposition = decompose (TC, DC, this ->getType ());
562
- return intersect (decomposition, other, TC, DC);
555
+ return decomposition. intersect (other, TC, DC);
563
556
} else {
564
557
return other;
565
558
}
@@ -580,7 +573,7 @@ namespace {
580
573
std::transform (this ->getSpaces ().begin (), this ->getSpaces ().end (),
581
574
std::back_inserter (newSubSpaces),
582
575
[&](const Space &subSpace) {
583
- return intersect (subSpace, other, TC, DC);
576
+ return subSpace. intersect (other, TC, DC);
584
577
});
585
578
return Space::forConstructor (this ->getType (), this ->getHead (),
586
579
this ->canDowngradeToWarning (),
@@ -605,7 +598,7 @@ namespace {
605
598
auto j = other.getSpaces ().begin ();
606
599
for (; i != this ->getSpaces ().end () && j != other.getSpaces ().end ();
607
600
++i, ++j) {
608
- auto result = intersect (*i, *j, TC, DC);
601
+ auto result = i-> intersect (*j, TC, DC);
609
602
// If at least one of the constructor sub-spaces is empty,
610
603
// it makes the whole space empty as well.
611
604
if (result.isEmpty ()) {
@@ -619,7 +612,7 @@ namespace {
619
612
620
613
PAIRCASE (SpaceKind::UnknownCase, SpaceKind::Type):
621
614
PAIRCASE (SpaceKind::UnknownCase, SpaceKind::Constructor):
622
- return intersect (other, *this , TC, DC);
615
+ return other. intersect (*this , TC, DC);
623
616
PAIRCASE (SpaceKind::UnknownCase, SpaceKind::UnknownCase):
624
617
if (other.isAllowedButNotRequired ())
625
618
return other;
@@ -635,7 +628,7 @@ namespace {
635
628
636
629
if (canDecompose (other.getType (), DC)) {
637
630
auto decomposition = decompose (TC, DC, other.getType ());
638
- return intersect (* this , decomposition, TC, DC);
631
+ return this -> intersect (decomposition, TC, DC);
639
632
}
640
633
return Space ();
641
634
}
@@ -645,7 +638,7 @@ namespace {
645
638
return Space ();
646
639
647
640
PAIRCASE (SpaceKind::Type, SpaceKind::BooleanConstant): {
648
- return intersect (other, *this , TC, DC);
641
+ return other. intersect (*this , TC, DC);
649
642
}
650
643
651
644
PAIRCASE (SpaceKind::Empty, SpaceKind::BooleanConstant):
@@ -689,10 +682,10 @@ namespace {
689
682
return Space ();
690
683
} else if (canDecompose (this ->getType (), DC)) {
691
684
auto decomposition = decompose (TC, DC, this ->getType ());
692
- return intersect (decomposition, other, TC, DC);
685
+ return decomposition. intersect (other, TC, DC);
693
686
} else if (canDecompose (other.getType (), DC)) {
694
687
auto decomposition = decompose (TC, DC, other.getType ());
695
- return intersect (* this , decomposition, TC, DC);
688
+ return this -> intersect (decomposition, TC, DC);
696
689
}
697
690
return Space ();
698
691
}
@@ -783,7 +776,7 @@ namespace {
783
776
auto &s2 = *j;
784
777
// If the intersection of each subspace is ever empty then the
785
778
// 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 ()) {
787
780
return *this ;
788
781
}
789
782
0 commit comments