Skip to content

Commit 1c5f9bc

Browse files
committed
IRGen: Emit the protocol requirement descriptor async flag for initializers
rdar://88180938
1 parent dde3291 commit 1c5f9bc

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/IRGen/GenMeta.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,12 @@ static bool needsForeignMetadataCompletionFunction(IRGenModule &IGM,
240240

241241
template <class Flags>
242242
static Flags getMethodDescriptorFlags(ValueDecl *fn) {
243-
if (isa<ConstructorDecl>(fn))
244-
return Flags(Flags::Kind::Init); // 'init' is considered static
243+
if (isa<ConstructorDecl>(fn)) {
244+
auto flags = Flags(Flags::Kind::Init); // 'init' is considered static
245+
if (auto *afd = dyn_cast<AbstractFunctionDecl>(fn))
246+
flags = flags.withIsAsync(afd->hasAsync());
247+
return flags;
248+
}
245249

246250
auto kind = [&] {
247251
auto accessor = dyn_cast<AccessorDecl>(fn);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %target-swift-frontend -emit-ir -disable-availability-checking %s | %FileCheck -check-prefix CHECK -check-prefix CHECK-%target-cpu -check-prefix CHECK-%target-import-type %s
2+
// REQUIRES: concurrency
3+
4+
// Make sure that the protocol requirement descriptor includes the async flag.
5+
// CHECK: @"$s23protocol_req_descriptor12RepoProtocolMp" = {{.*}}%swift.protocol_requirement { i32 34, i32 0 }, %swift.protocol_requirement { i32 49, i32 0 } }>
6+
protocol RepoProtocol {
7+
init() async
8+
func run() async
9+
}
10+
11+
actor Impl: RepoProtocol {
12+
init() async {}
13+
func run() async {}
14+
}

0 commit comments

Comments
 (0)