diff --git a/lib/IRGen/GenProto.cpp b/lib/IRGen/GenProto.cpp index 2cb7ba801893d..3e7d81c2ca5fd 100644 --- a/lib/IRGen/GenProto.cpp +++ b/lib/IRGen/GenProto.cpp @@ -2749,12 +2749,10 @@ static void addAbstractConditionalRequirements( auto *proto = req.getSecondType()->castTo()->getDecl(); auto ty = req.getFirstType()->getCanonicalType(); - if (!isa(ty)) + auto archetype = dyn_cast(ty); + if (!archetype) continue; - auto conformance = subMap.lookupConformance(ty, proto); - if (!conformance.isAbstract()) - continue; - requirements.insert({ty, conformance.getAbstract()}); + requirements.insert({ty, proto}); } // Recursively add conditional requirements. for (auto &conf : subMap.getConformances()) { diff --git a/test/IRGen/partial_apply_forwarder.sil b/test/IRGen/partial_apply_forwarder.sil index 50ead1c5882c4..9c155222a0812 100644 --- a/test/IRGen/partial_apply_forwarder.sil +++ b/test/IRGen/partial_apply_forwarder.sil @@ -255,6 +255,9 @@ protocol MyEquatable { static func isEqual (lhs: Self, rhs: Self) -> Builtin.Int1 } +protocol MyExtended : MyEquatable { + func extended() +} public struct Inner { public init() public init(_ e: Element) @@ -278,7 +281,7 @@ public struct Outermost { sil @$closure : $@convention(method) (Outer, Outer, @thin Outer.Type) -> Builtin.Int1 sil @$closure2 : $@convention(method) (Outermost, Outermost, @thin Outermost.Type) -> Builtin.Int1 -sil @$dont_crash_test_capture_specialized_conditional_conformance : $@convention(thin) (Outer>) -> () { +sil @$dont_crash_test_capture_specialized_conditional_conformance : $@convention(thin) (Outer>) -> () { bb0(%0 : $Outer>): %2 = alloc_stack $Outer> store %0 to %2 : $*Outer> @@ -291,7 +294,24 @@ bb0(%0 : $Outer>): return %15 : $() } -sil @$dont_crash_test_capture_specialized_conditional_conformance_nested : $@convention(thin) (Outer>) -> () { +protocol AssocType { + associatedtype A : MyExtended +} + +sil @$dont_crash_test_capture_specialized_conditional_conformance_associated_type : $@convention(thin) (Outer>) -> () { +bb0(%0 : $Outer>): + %2 = alloc_stack $Outer> + store %0 to %2 : $*Outer> + %4 = metatype $@thin Outer>.Type + %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 + %6 = partial_apply [callee_guaranteed] %5>(%4) : $@convention(method) <τ_0_0 where τ_0_0 : MyEquatable> (Outer<τ_0_0>, Outer<τ_0_0>, @thin Outer<τ_0_0>.Type) -> Builtin.Int1 + strong_release %6 : $@callee_guaranteed (Outer>, Outer>) -> Builtin.Int1 + dealloc_stack %2 : $*Outer> + %15 = tuple () + return %15 : $() +} + +sil @$dont_crash_test_capture_specialized_conditional_conformance_nested : $@convention(thin) (Outer>) -> () { bb0(%0 : $Outer>): %4 = metatype $@thin Outermost>>.Type %5 = function_ref @$closure2 : $@convention(method) (Outermost, Outermost, @thin Outermost.Type) -> Builtin.Int1