Skip to content

Commit 79d39cc

Browse files
committed
[Concurrency] Handle ExecutorJob/Job better during renaming period
1 parent ecde61a commit 79d39cc

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
@@ -1276,7 +1276,7 @@ void swift::tryDiagnoseExecutorConformance(ASTContext &C,
12761276
auto module = nominal->getParentModule();
12771277
Type nominalTy = nominal->getDeclaredInterfaceType();
12781278

1279-
// enqueue(_: UnownedJob)
1279+
// enqueue(_:)
12801280
auto enqueueDeclName = DeclName(C, DeclBaseName(C.Id_enqueue), { Identifier() });
12811281

12821282
FuncDecl *unownedEnqueueRequirement = nullptr;
@@ -1293,8 +1293,16 @@ void swift::tryDiagnoseExecutorConformance(ASTContext &C,
12931293
if (funcDecl->getParameters()->size() != 1)
12941294
continue;
12951295
if (auto param = funcDecl->getParameters()->front()) {
1296-
if (C.getJobDecl() &&
1297-
param->getType()->isEqual(C.getJobDecl()->getDeclaredInterfaceType())) {
1296+
StructDecl* jobDecl;
1297+
if (auto decl = C.getExecutorJobDecl()) {
1298+
jobDecl = decl;
1299+
} else if (auto decl = C.getJobDecl()) {
1300+
// old standard library, before we introduced the `typealias Job = ExecutorJob`
1301+
jobDecl = decl;
1302+
}
1303+
1304+
if (jobDecl &&
1305+
param->getType()->isEqual(jobDecl->getDeclaredInterfaceType())) {
12981306
assert(moveOnlyEnqueueRequirement == nullptr);
12991307
moveOnlyEnqueueRequirement = funcDecl;
13001308
} else if (param->getType()->isEqual(C.getUnownedJobDecl()->getDeclaredInterfaceType())) {

0 commit comments

Comments
 (0)