@@ -378,11 +378,8 @@ static void desugarConformanceRequirement(
378378 // Only permit type-parameter subjects.
379379 errors.push_back (
380380 RequirementError::forInvalidRequirementSubject (req, loc));
381- } else if (subject->isParameterPack ()) {
382- // Disallow parameter packs for now.
383- errors.push_back (RequirementError::forInvalidInverseSubject (req, loc));
384381 } else {
385- // Record inverse .
382+ // Record and desugar inverses .
386383 auto &ctx = req.getFirstType ()->getASTContext ();
387384 for (auto ip : compositionType->getInverses ())
388385 inverses.push_back ({req.getFirstType (),
@@ -746,11 +743,30 @@ void swift::rewriting::applyInverses(
746743 SmallVectorImpl<StructuralRequirement> &result,
747744 SmallVectorImpl<RequirementError> &errors) {
748745
749- // Summarize the inverses and flag ones that are incorrect.
746+ // No inverses to even validate.
747+ if (inverseList.empty ())
748+ return ;
749+
750+ const bool allowInverseOnAssocType =
751+ ctx.LangOpts .hasFeature (Feature::SuppressedAssociatedTypes);
752+
753+ // Summarize the inverses and diagnose ones that are incorrect.
750754 llvm::DenseMap<CanType, InvertibleProtocolSet> inverses;
751755 for (auto inverse : inverseList) {
752756 auto canSubject = inverse.subject ->getCanonicalType ();
753757
758+ // Inverses on associated types are experimental.
759+ if (!allowInverseOnAssocType && canSubject->is <DependentMemberType>()) {
760+ errors.push_back (RequirementError::forInvalidInverseSubject (inverse));
761+ continue ;
762+ }
763+
764+ // Noncopyable checking support for parameter packs is not implemented yet.
765+ if (canSubject->isParameterPack ()) {
766+ errors.push_back (RequirementError::forInvalidInverseSubject (inverse));
767+ continue ;
768+ }
769+
754770 // WARNING: possible quadratic behavior, but should be OK in practice.
755771 auto notInScope = llvm::none_of (gps, [=](Type t) {
756772 return t->getCanonicalType () == canSubject;
0 commit comments