Skip to content

Commit 8a2bfb0

Browse files
committed
No need to lookup the conformance we can just take the protocol from the requirement
1 parent 478e13b commit 8a2bfb0

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

lib/IRGen/GenProto.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2752,11 +2752,7 @@ static void addAbstractConditionalRequirements(
27522752
auto archetype = dyn_cast<ArchetypeType>(ty);
27532753
if (!archetype)
27542754
continue;
2755-
auto *genericEnv = archetype->getGenericEnvironment();
2756-
auto conformance =
2757-
genericEnv->getForwardingSubstitutionMap().lookupConformance(ty, proto);
2758-
assert(conformance.isAbstract());
2759-
requirements.insert({ty, conformance.getAbstract()});
2755+
requirements.insert({ty, proto});
27602756
}
27612757
// Recursively add conditional requirements.
27622758
for (auto &conf : subMap.getConformances()) {

test/IRGen/partial_apply_forwarder.sil

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ protocol MyEquatable {
255255
static func isEqual (lhs: Self, rhs: Self) -> Builtin.Int1
256256
}
257257

258+
protocol MyExtended : MyEquatable {
259+
func extended()
260+
}
258261
public struct Inner<Element> {
259262
public init()
260263
public init(_ e: Element)
@@ -278,7 +281,7 @@ public struct Outermost<Value> {
278281
sil @$closure : $@convention(method) <Value where Value : MyEquatable> (Outer<Value>, Outer<Value>, @thin Outer<Value>.Type) -> Builtin.Int1
279282
sil @$closure2 : $@convention(method) <Value where Value : MyEquatable> (Outermost<Value>, Outermost<Value>, @thin Outermost<Value>.Type) -> Builtin.Int1
280283

281-
sil @$dont_crash_test_capture_specialized_conditional_conformance : $@convention(thin) <Element where Element : MyEquatable> (Outer<Inner<Element>>) -> () {
284+
sil @$dont_crash_test_capture_specialized_conditional_conformance : $@convention(thin) <Element where Element : MyExtended> (Outer<Inner<Element>>) -> () {
282285
bb0(%0 : $Outer<Inner<Element>>):
283286
%2 = alloc_stack $Outer<Inner<Element>>
284287
store %0 to %2 : $*Outer<Inner<Element>>
@@ -291,6 +294,23 @@ bb0(%0 : $Outer<Inner<Element>>):
291294
return %15 : $()
292295
}
293296

297+
protocol AssocType {
298+
associatedtype A : MyExtended
299+
}
300+
301+
sil @$dont_crash_test_capture_specialized_conditional_conformance_associated_type : $@convention(thin) <Element where Element : AssocType> (Outer<Inner<Element.A>>) -> () {
302+
bb0(%0 : $Outer<Inner<Element.A>>):
303+
%2 = alloc_stack $Outer<Inner<Element.A>>
304+
store %0 to %2 : $*Outer<Inner<Element.A>>
305+
%4 = metatype $@thin Outer<Inner<Element.A>>.Type
306+
%5 = function_ref @$closure : $@convention(method) <τ_0_0 where τ_0_0 : MyEquatable> (Outer<τ_0_0>, Outer<τ_0_0>, @thin Outer<τ_0_0>.Type) -> Builtin.Int1
307+
%6 = partial_apply [callee_guaranteed] %5<Inner<Element.A>>(%4) : $@convention(method) <τ_0_0 where τ_0_0 : MyEquatable> (Outer<τ_0_0>, Outer<τ_0_0>, @thin Outer<τ_0_0>.Type) -> Builtin.Int1
308+
strong_release %6 : $@callee_guaranteed (Outer<Inner<Element.A>>, Outer<Inner<Element.A>>) -> Builtin.Int1
309+
dealloc_stack %2 : $*Outer<Inner<Element.A>>
310+
%15 = tuple ()
311+
return %15 : $()
312+
}
313+
294314
sil @$dont_crash_test_capture_specialized_conditional_conformance_nested : $@convention(thin) <A, B, Element where Element : MyEquatable> (Outer<Inner<Element>>) -> () {
295315
bb0(%0 : $Outer<Inner<Element>>):
296316
%4 = metatype $@thin Outermost<Outer<Inner<Element>>>.Type

0 commit comments

Comments
 (0)