Skip to content

Commit d2726c3

Browse files
committed
[Async CC] Don't lookup known archetype conformance.
Previously, when saving NecessaryBindings for an async function, if a type that was passed-in happened to be an archetype, a lookup for that type's conformance would always be done. However, that lookup was not always necessary or possible such as in the case where both the metadata and the witness table were provided to the function in an async context. Here, that is fixed by using the conformance that was seen when constructing the NecessaryBindings if one is available. rdar://problem/72397303
1 parent 573ee3e commit d2726c3

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/IRGen/GenProto.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2712,12 +2712,14 @@ static void save(const NecessaryBindings &bindings, IRGenFunction &IGF,
27122712
[&](GenericRequirement requirement) -> llvm::Value * {
27132713
CanType type = requirement.TypeParameter;
27142714
if (auto protocol = requirement.Protocol) {
2715-
if (auto archetype = dyn_cast<ArchetypeType>(type)) {
2715+
CanArchetypeType archetype;
2716+
ProtocolConformanceRef conformance =
2717+
bindings.getConformance(requirement);
2718+
if ((archetype = dyn_cast<ArchetypeType>(type)) && !conformance) {
27162719
auto wtable =
27172720
emitArchetypeWitnessTableRef(IGF, archetype, protocol);
27182721
return transform(requirement, wtable);
27192722
} else {
2720-
auto conformance = bindings.getConformance(requirement);
27212723
auto wtable = emitWitnessTableRef(IGF, type, conformance);
27222724
return transform(requirement, wtable);
27232725
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %target-swift-frontend %s -emit-ir -enable-experimental-concurrency
2+
3+
protocol P {
4+
func f<T>() async throws -> T?
5+
}
6+
extension P {
7+
func f<T>() async throws -> T? { nil }
8+
}
9+
class X: P {}
10+

0 commit comments

Comments
 (0)