Skip to content

Commit 2b47815

Browse files
committed
IRGen: Lookup the conformance of an archetype in the right substitution map when computing necessary bindings of abstract cnditional requirements
SR-12853
1 parent f7fd83d commit 2b47815

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/IRGen/GenProto.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2749,9 +2749,12 @@ static void addAbstractConditionalRequirements(
27492749
auto *proto =
27502750
req.getSecondType()->castTo<ProtocolType>()->getDecl();
27512751
auto ty = req.getFirstType()->getCanonicalType();
2752-
if (!isa<ArchetypeType>(ty))
2752+
auto archetype = dyn_cast<ArchetypeType>(ty);
2753+
if (!archetype)
27532754
continue;
2754-
auto conformance = subMap.lookupConformance(ty, proto);
2755+
auto *genericEnv = archetype->getGenericEnvironment();
2756+
auto conformance =
2757+
genericEnv->getForwardingSubstitutionMap().lookupConformance(ty, proto);
27552758
if (!conformance.isAbstract())
27562759
continue;
27572760
requirements.insert({ty, conformance.getAbstract()});

test/IRGen/partial_apply_forwarder.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ bb0(%0 : $Outer<Inner<Element>>):
291291
return %15 : $()
292292
}
293293

294-
sil @$dont_crash_test_capture_specialized_conditional_conformance_nested : $@convention(thin) <Element where Element : MyEquatable> (Outer<Inner<Element>>) -> () {
294+
sil @$dont_crash_test_capture_specialized_conditional_conformance_nested : $@convention(thin) <A, B, Element where Element : MyEquatable> (Outer<Inner<Element>>) -> () {
295295
bb0(%0 : $Outer<Inner<Element>>):
296296
%4 = metatype $@thin Outermost<Outer<Inner<Element>>>.Type
297297
%5 = function_ref @$closure2 : $@convention(method) <Value where Value : MyEquatable> (Outermost<Value>, Outermost<Value>, @thin Outermost<Value>.Type) -> Builtin.Int1

0 commit comments

Comments
 (0)