Skip to content

Commit e713cbd

Browse files
committed
[ConstraintSystem] With designated types enabled, use fewer partitions.
In 119864a I moved the consideration of top-level operators sooner when the designated types feature is enabled, and that fixed some source compatibility issues that show up in our test suite, but also introduced a new one. For maximum source compatibility we'll just split the partitions up into the operators from designated types, followed by operators that are not deprecated or disabled, followed by the deprecated ones, and finally the disabled ones.
1 parent 7a3ed15 commit e713cbd

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,10 @@ void ConstraintSystem::partitionForDesignatedTypes(
17231723
auto *parentDC = funcDecl->getParent();
17241724
auto *parentDecl = parentDC->getSelfNominalTypeDecl();
17251725

1726+
// Skip anything not defined in a nominal type.
1727+
if (!parentDecl)
1728+
return false;
1729+
17261730
for (auto designatedTypeIndex : indices(designatedNominalTypes)) {
17271731
auto *designatedNominal =
17281732
designatedNominalTypes[designatedTypeIndex];
@@ -1807,7 +1811,6 @@ void ConstraintSystem::partitionDisjunction(
18071811

18081812
SmallVector<unsigned, 4> disabled;
18091813
SmallVector<unsigned, 4> unavailable;
1810-
SmallVector<unsigned, 4> globalScope;
18111814

18121815
// First collect disabled constraints.
18131816
forEachChoice(Choices, [&](unsigned index, Constraint *constraint) -> bool {
@@ -1831,20 +1834,6 @@ void ConstraintSystem::partitionDisjunction(
18311834
});
18321835
}
18331836

1834-
// Collect everything at the global scope.
1835-
forEachChoice(Choices, [&](unsigned index, Constraint *constraint) -> bool {
1836-
auto *decl = constraint->getOverloadChoice().getDecl();
1837-
auto *funcDecl = cast<FuncDecl>(decl);
1838-
1839-
// Skip anything defined within a type.
1840-
auto *parentDecl = funcDecl->getParent()->getAsDecl();
1841-
if (parentDecl)
1842-
return false;
1843-
1844-
globalScope.push_back(index);
1845-
return true;
1846-
});
1847-
18481837
// Local function to create the next partition based on the options
18491838
// passed in.
18501839
PartitionAppendCallback appendPartition =
@@ -1857,9 +1846,6 @@ void ConstraintSystem::partitionDisjunction(
18571846

18581847
partitionForDesignatedTypes(Choices, forEachChoice, appendPartition);
18591848

1860-
// Add all the things defined at global scope.
1861-
appendPartition(globalScope);
1862-
18631849
SmallVector<unsigned, 4> everythingElse;
18641850
// Gather the remaining options.
18651851
forEachChoice(Choices, [&](unsigned index, Constraint *constraint) -> bool {

0 commit comments

Comments
 (0)