@@ -1349,6 +1349,10 @@ bool swift::_swift_class_isSubclass(const Metadata *subclass,
13491349 return isSubclass (subclass, superclass);
13501350}
13511351
1352+ static std::optional<TypeLookupError>
1353+ checkInvertibleRequirements (const Metadata *type,
1354+ InvertibleProtocolSet ignored);
1355+
13521356static std::optional<TypeLookupError>
13531357checkGenericRequirement (
13541358 const GenericRequirementDescriptor &req,
@@ -1445,8 +1449,10 @@ checkGenericRequirement(
14451449 }
14461450 case GenericRequirementKind::InvertedProtocols: {
14471451 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+ }
14501456
14511457 // Expand the suppression set so we can record these protocols.
14521458 if (index >= suppressed.size ()) {
@@ -1613,8 +1619,18 @@ checkGenericPackRequirement(
16131619
16141620 case GenericRequirementKind::InvertedProtocols: {
16151621 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+ }
16181634
16191635 // Expand the suppression set so we can record these protocols.
16201636 if (index >= suppressed.size ()) {
@@ -1632,10 +1648,6 @@ checkGenericPackRequirement(
16321648 (unsigned )req.getKind ());
16331649}
16341650
1635- static std::optional<TypeLookupError>
1636- checkInvertibleRequirements (const Metadata *type,
1637- InvertibleProtocolSet ignored);
1638-
16391651static std::optional<TypeLookupError>
16401652checkInvertibleRequirementsStructural (const Metadata *type,
16411653 InvertibleProtocolSet ignored) {
0 commit comments