diff --git a/lib/IRGen/TBDGen.cpp b/lib/IRGen/TBDGen.cpp index 75f55823bd376..d4f1efbe0956c 100644 --- a/lib/IRGen/TBDGen.cpp +++ b/lib/IRGen/TBDGen.cpp @@ -472,9 +472,16 @@ void TBDGenVisitor::addProtocolWitnessThunk(RootProtocolConformance *C, ValueDecl *requirementDecl) { Mangle::ASTMangler Mangler; + std::string decorated = Mangler.mangleWitnessThunk(C, requirementDecl); // FIXME: We should have a SILDeclRef SymbolSource for this. - addSymbol(Mangler.mangleWitnessThunk(C, requirementDecl), - SymbolSource::forUnknown()); + addSymbol(decorated, SymbolSource::forUnknown()); + + if (requirementDecl->isProtocolRequirement()) { + ValueDecl *PWT = C->getWitness(requirementDecl).getDecl(); + if (const auto *AFD = dyn_cast(PWT)) + if (AFD->hasAsync()) + addSymbol(decorated + "Tu", SymbolSource::forUnknown()); + } } void TBDGenVisitor::addFirstFileSymbols() { diff --git a/test/IRGen/serialised-pwt-afp.swift b/test/IRGen/serialised-pwt-afp.swift new file mode 100644 index 0000000000000..155dd92529d2a --- /dev/null +++ b/test/IRGen/serialised-pwt-afp.swift @@ -0,0 +1,23 @@ +// RUN: %empty-directory(%t) +// RUN: %target-swift-frontend -disable-availability-checking -emit-module -emit-module-path %t/P.swiftmodule -parse-as-library -module-name P -DP %s +// RUN: %target-swift-frontend -disable-availability-checking -I%t -parse-as-library -module-name Q -c %s -o /dev/null -validate-tbd-against-ir=missing + +// REQUIRES: concurrency + +#if P +public protocol P { + func f() async +} +#else +import P + +protocol Q: P { } + +extension Q { + public func f() async { } +} + +public struct S: Q { + public init() { } +} +#endif