@@ -394,11 +394,23 @@ static CanGenericSignature buildDifferentiableGenericSignature(CanGenericSignatu
394394 if (origTypeOfAbstraction) {
395395 (void ) origTypeOfAbstraction.findIf ([&](Type t) -> bool {
396396 if (auto *at = t->getAs <ArchetypeType>()) {
397- types.insert (at->getInterfaceType ()->getCanonicalType ());
398- for (auto *proto : at->getConformsTo ()) {
399- reqs.push_back (Requirement (RequirementKind::Conformance,
400- at->getInterfaceType (),
401- proto->getDeclaredInterfaceType ()));
397+ auto interfaceTy = at->getInterfaceType ();
398+ auto genericParams = sig.getGenericParams ();
399+
400+ // The GSB used to drop requirements which reference non-existent
401+ // generic parameters, whereas the RequirementMachine asserts now.
402+ // Filter thes requirements out explicitly to preserve the old
403+ // behavior.
404+ if (std::find_if (genericParams.begin (), genericParams.end (),
405+ [interfaceTy](CanGenericTypeParamType t) -> bool {
406+ return t->isEqual (interfaceTy->getRootGenericParam ());
407+ }) != genericParams.end ()) {
408+ types.insert (interfaceTy->getCanonicalType ());
409+ for (auto *proto : at->getConformsTo ()) {
410+ reqs.push_back (Requirement (RequirementKind::Conformance,
411+ interfaceTy,
412+ proto->getDeclaredInterfaceType ()));
413+ }
402414 }
403415 }
404416 return false ;
0 commit comments