File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
test/AutoDiff/SILOptimizer Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -406,11 +406,33 @@ static CanGenericSignature buildDifferentiableGenericSignature(CanGenericSignatu
406406 return t->isEqual (interfaceTy->getRootGenericParam ());
407407 }) != genericParams.end ()) {
408408 types.insert (interfaceTy->getCanonicalType ());
409+
409410 for (auto *proto : at->getConformsTo ()) {
410411 reqs.push_back (Requirement (RequirementKind::Conformance,
411412 interfaceTy,
412413 proto->getDeclaredInterfaceType ()));
413414 }
415+
416+ // The GSB would add conformance requirements if a nested type
417+ // requirement involving a resolved DependentMemberType was added;
418+ // eg, if you start with <T> and add T.[P]A == Int, it would also
419+ // add the conformance requirement T : P.
420+ //
421+ // This was not an intended behavior on the part of the GSB, and the
422+ // logic here is a complete mess, so just simulate the old behavior
423+ // here.
424+ auto parentTy = interfaceTy;
425+ while (parentTy) {
426+ if (auto memberTy = parentTy->getAs <DependentMemberType>()) {
427+ parentTy = memberTy->getBase ();
428+ if (auto *assocTy = memberTy->getAssocType ()) {
429+ reqs.push_back (Requirement (RequirementKind::Conformance,
430+ parentTy,
431+ assocTy->getProtocol ()->getDeclaredInterfaceType ()));
432+ }
433+ } else
434+ parentTy = Type ();
435+ }
414436 }
415437 }
416438 return false ;
Original file line number Diff line number Diff line change 1- // RUN: %target-swift-emit-sil -verify %s | %FileCheck %s -check-prefix=CHECK-SIL
1+ // RUN: %target-swift-emit-sil -verify %s -requirement-machine-abstract-signatures=verify | %FileCheck %s -check-prefix=CHECK-SIL
22
33import _Differentiation
44
You can’t perform that action at this time.
0 commit comments