Skip to content

Commit c83a988

Browse files
committed
[Concurrency] Handle ExecutorJob/Job better during renaming period
1 parent 65ba63d commit c83a988

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

include/swift/AST/KnownSDKTypes.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ KNOWN_SDK_TYPE_DECL(ObjectiveC, ObjCBool, StructDecl, 0)
3939
// standardized
4040
KNOWN_SDK_TYPE_DECL(Concurrency, UnsafeContinuation, NominalTypeDecl, 2)
4141
KNOWN_SDK_TYPE_DECL(Concurrency, MainActor, NominalTypeDecl, 0)
42-
KNOWN_SDK_TYPE_DECL(Concurrency, Job, StructDecl, 0)
42+
KNOWN_SDK_TYPE_DECL(Concurrency, Job, StructDecl, 0) // TODO: remove in favor of ExecutorJob
43+
KNOWN_SDK_TYPE_DECL(Concurrency, ExecutorJob, StructDecl, 0)
4344
KNOWN_SDK_TYPE_DECL(Concurrency, UnownedJob, StructDecl, 0)
4445
KNOWN_SDK_TYPE_DECL(Concurrency, Executor, NominalTypeDecl, 0)
4546
KNOWN_SDK_TYPE_DECL(Concurrency, SerialExecutor, NominalTypeDecl, 0)

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,7 @@ void swift::tryDiagnoseExecutorConformance(ASTContext &C,
12661266
auto module = nominal->getParentModule();
12671267
Type nominalTy = nominal->getDeclaredInterfaceType();
12681268

1269-
// enqueue(_: UnownedJob)
1269+
// enqueue(_:)
12701270
auto enqueueDeclName = DeclName(C, DeclBaseName(C.Id_enqueue), { Identifier() });
12711271

12721272
FuncDecl *unownedEnqueueRequirement = nullptr;
@@ -1283,8 +1283,16 @@ void swift::tryDiagnoseExecutorConformance(ASTContext &C,
12831283
if (funcDecl->getParameters()->size() != 1)
12841284
continue;
12851285
if (auto param = funcDecl->getParameters()->front()) {
1286-
if (C.getJobDecl() &&
1287-
param->getType()->isEqual(C.getJobDecl()->getDeclaredInterfaceType())) {
1286+
StructDecl* jobDecl;
1287+
if (auto decl = C.getExecutorJobDecl()) {
1288+
jobDecl = decl;
1289+
} else if (auto decl = C.getJobDecl()) {
1290+
// old standard library, before we introduced the `typealias Job = ExecutorJob`
1291+
jobDecl = decl;
1292+
}
1293+
1294+
if (jobDecl &&
1295+
param->getType()->isEqual(jobDecl->getDeclaredInterfaceType())) {
12881296
assert(moveOnlyEnqueueRequirement == nullptr);
12891297
moveOnlyEnqueueRequirement = funcDecl;
12901298
} else if (param->getType()->isEqual(C.getUnownedJobDecl()->getDeclaredInterfaceType())) {

0 commit comments

Comments
 (0)