@@ -1685,41 +1685,40 @@ getOperatorDesignatedNominalTypes(Constraint *bindOverload) {
1685
1685
1686
1686
void ConstraintSystem::partitionForDesignatedTypes (
1687
1687
ArrayRef<Constraint *> Choices, ConstraintMatchLoop forEachChoice,
1688
- PartitionAppendCallback appendPartition,
1689
- SmallVectorImpl<SmallVector<unsigned , 4 >> &definedInDesignatedType,
1690
- SmallVectorImpl<SmallVector<unsigned , 4 >>
1691
- &definedInExtensionOfDesignatedType) {
1688
+ PartitionAppendCallback appendPartition) {
1692
1689
1693
1690
auto designatedNominalTypes = getOperatorDesignatedNominalTypes (Choices[0 ]);
1694
1691
if (designatedNominalTypes.empty ())
1695
1692
return ;
1696
1693
1694
+ SmallVector<SmallVector<unsigned , 4 >, 4 > definedInDesignatedType;
1695
+ SmallVector<SmallVector<unsigned , 4 >, 4 > definedInExtensionOfDesignatedType;
1696
+
1697
1697
auto examineConstraint =
1698
1698
[&](unsigned constraintIndex, Constraint *constraint) -> bool {
1699
1699
auto *decl = constraint->getOverloadChoice ().getDecl ();
1700
1700
auto *funcDecl = cast<FuncDecl>(decl);
1701
1701
1702
- auto *parentDecl = funcDecl->getParent ()->getAsDecl ();
1702
+ auto *parentDC = funcDecl->getParent ();
1703
+ auto *parentDecl = parentDC->getAsDecl ();
1704
+
1705
+ if (parentDC->isExtensionContext ())
1706
+ parentDecl = cast<ExtensionDecl>(parentDecl)->getExtendedNominal ();
1707
+
1703
1708
for (auto designatedTypeIndex : indices (designatedNominalTypes)) {
1704
1709
auto *designatedNominal =
1705
1710
designatedNominalTypes[designatedTypeIndex];
1706
1711
1707
- if (parentDecl == designatedNominal) {
1708
- auto &constraints = definedInDesignatedType[designatedTypeIndex];
1709
- constraints.push_back (constraintIndex);
1710
- return true ;
1711
- }
1712
-
1713
- auto *extensionDecl = dyn_cast<ExtensionDecl>(parentDecl);
1714
- if (!extensionDecl)
1712
+ if (parentDecl != designatedNominal)
1715
1713
continue ;
1716
1714
1717
- if (extensionDecl->getExtendedNominal () == designatedNominal) {
1718
- auto &constraints =
1719
- definedInExtensionOfDesignatedType[designatedTypeIndex];
1720
- constraints.push_back (constraintIndex);
1721
- return true ;
1722
- }
1715
+ auto &constraints =
1716
+ parentDC->isExtensionContext ()
1717
+ ? definedInExtensionOfDesignatedType[designatedTypeIndex]
1718
+ : definedInDesignatedType[designatedTypeIndex];
1719
+
1720
+ constraints.push_back (constraintIndex);
1721
+ return true ;
1723
1722
}
1724
1723
1725
1724
return false ;
@@ -1839,12 +1838,7 @@ void ConstraintSystem::partitionDisjunction(
1839
1838
}
1840
1839
};
1841
1840
1842
- SmallVector<SmallVector<unsigned , 4 >, 4 > definedInDesignatedType;
1843
- SmallVector<SmallVector<unsigned , 4 >, 4 > definedInExtensionOfDesignatedType;
1844
-
1845
- partitionForDesignatedTypes (Choices, forEachChoice, appendPartition,
1846
- definedInDesignatedType,
1847
- definedInExtensionOfDesignatedType);
1841
+ partitionForDesignatedTypes (Choices, forEachChoice, appendPartition);
1848
1842
1849
1843
SmallVector<unsigned , 4 > everythingElse;
1850
1844
// Gather the remaining options.
0 commit comments