@@ -1349,6 +1349,10 @@ bool swift::_swift_class_isSubclass(const Metadata *subclass,
1349
1349
return isSubclass (subclass, superclass);
1350
1350
}
1351
1351
1352
+ static std::optional<TypeLookupError>
1353
+ checkInvertibleRequirements (const Metadata *type,
1354
+ InvertibleProtocolSet ignored);
1355
+
1352
1356
static std::optional<TypeLookupError>
1353
1357
checkGenericRequirement (
1354
1358
const GenericRequirementDescriptor &req,
@@ -1445,8 +1449,10 @@ checkGenericRequirement(
1445
1449
}
1446
1450
case GenericRequirementKind::InvertedProtocols: {
1447
1451
uint16_t index = req.getInvertedProtocolsGenericParamIndex ();
1448
- if (index == 0xFFFF )
1449
- return TYPE_LOOKUP_ERROR_FMT (" unable to suppress protocols" );
1452
+ if (index == 0xFFFF ) {
1453
+ return checkInvertibleRequirements (subjectType,
1454
+ req.getInvertedProtocols ());
1455
+ }
1450
1456
1451
1457
// Expand the suppression set so we can record these protocols.
1452
1458
if (index >= suppressed.size ()) {
@@ -1613,8 +1619,18 @@ checkGenericPackRequirement(
1613
1619
1614
1620
case GenericRequirementKind::InvertedProtocols: {
1615
1621
uint16_t index = req.getInvertedProtocolsGenericParamIndex ();
1616
- if (index == 0xFFFF )
1617
- return TYPE_LOOKUP_ERROR_FMT (" unable to suppress protocols" );
1622
+ if (index == 0xFFFF ) {
1623
+ // Check that each pack element meets the invertible requirements.
1624
+ for (size_t i = 0 , e = subjectType.getNumElements (); i < e; ++i) {
1625
+ const Metadata *elt = subjectType.getElements ()[i];
1626
+
1627
+ if (auto error = checkInvertibleRequirements (
1628
+ elt, req.getInvertedProtocols ()))
1629
+ return error;
1630
+ }
1631
+
1632
+ return std::nullopt ;
1633
+ }
1618
1634
1619
1635
// Expand the suppression set so we can record these protocols.
1620
1636
if (index >= suppressed.size ()) {
@@ -1632,10 +1648,6 @@ checkGenericPackRequirement(
1632
1648
(unsigned )req.getKind ());
1633
1649
}
1634
1650
1635
- static std::optional<TypeLookupError>
1636
- checkInvertibleRequirements (const Metadata *type,
1637
- InvertibleProtocolSet ignored);
1638
-
1639
1651
static std::optional<TypeLookupError>
1640
1652
checkInvertibleRequirementsStructural (const Metadata *type,
1641
1653
InvertibleProtocolSet ignored) {
0 commit comments