Skip to content

Commit a2038f9

Browse files
committed
Address code review feedback and fix rebase typo in a test
1 parent a2b2324 commit a2038f9

File tree

6 files changed

+32
-10
lines changed

6 files changed

+32
-10
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3894,6 +3894,10 @@ namespace {
38943894

38953895
void recordCurrentContextIsolation(
38963896
CurrentContextIsolationExpr *isolationExpr) {
3897+
// If an actor has already been assigned, we're done.
3898+
if (isolationExpr->getActor())
3899+
return;
3900+
38973901
// #isolation does not work within an `@_unsafeInheritExecutor` function.
38983902
if (auto func = enclosingUnsafeInheritsExecutor(getDeclContext())) {
38993903
// This expression is always written as a macro #isolation in source,
@@ -3911,10 +3915,6 @@ namespace {
39113915
replaceUnsafeInheritExecutorWithDefaultedIsolationParam(func, diag);
39123916
}
39133917

3914-
// If an actor has already been assigned, we're done.
3915-
if (isolationExpr->getActor())
3916-
return;
3917-
39183918
auto loc = isolationExpr->getLoc();
39193919
auto isolation = getActorIsolationOfContext(
39203920
const_cast<DeclContext *>(getDeclContext()),

stdlib/public/Concurrency/CheckedContinuation.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,12 @@ public func withCheckedContinuation<T>(
299299
}
300300
}
301301

302+
// Note: hack to stage out @_unsafeInheritExecutor forms of various functions
303+
// in favor of #isolation. The _unsafeInheritExecutor_ prefix is meaningful
304+
// to the type checker.
305+
//
306+
// This function also doubles as an ABI-compatibility shim predating the
307+
// introduction of #isolation.
302308
@available(SwiftStdlib 5.1, *)
303309
@_unsafeInheritExecutor // ABI compatibility with Swift 5.1
304310
@_unavailableInEmbedded
@@ -359,6 +365,12 @@ public func withCheckedThrowingContinuation<T>(
359365
}
360366
}
361367

368+
// Note: hack to stage out @_unsafeInheritExecutor forms of various functions
369+
// in favor of #isolation. The _unsafeInheritExecutor_ prefix is meaningful
370+
// to the type checker.
371+
//
372+
// This function also doubles as an ABI-compatibility shim predating the
373+
// introduction of #isolation.
362374
@available(SwiftStdlib 5.1, *)
363375
@_unsafeInheritExecutor // ABI compatibility with Swift 5.1
364376
@_unavailableInEmbedded

stdlib/public/Concurrency/PartialAsyncTask.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -730,21 +730,23 @@ public func withUnsafeThrowingContinuation<T>(
730730
}
731731
}
732732

733-
// HACK: a version of withUnsafeContinuation that uses the unsafe
734-
// @_unsafeInheritExecutor.
733+
// Note: hack to stage out @_unsafeInheritExecutor forms of various functions
734+
// in favor of #isolation. The _unsafeInheritExecutor_ prefix is meaningful
735+
// to the type checker.
735736
@available(SwiftStdlib 5.1, *)
736737
@_alwaysEmitIntoClient
737738
@_unsafeInheritExecutor
738739
public func _unsafeInheritExecutor_withUnsafeContinuation<T>(
739740
_ fn: (UnsafeContinuation<T, Never>) -> Void
740-
) async -> T {
741+
) async -> sending T {
741742
return await Builtin.withUnsafeContinuation {
742743
fn(UnsafeContinuation<T, Never>($0))
743744
}
744745
}
745746

746-
// HACK: a version of withUnsafeThrowingContinuation that uses the unsafe
747-
// @_unsafeInheritExecutor.
747+
// Note: hack to stage out @_unsafeInheritExecutor forms of various functions
748+
// in favor of #isolation. The _unsafeInheritExecutor_ prefix is meaningful
749+
// to the type checker.
748750
@available(SwiftStdlib 5.1, *)
749751
@_alwaysEmitIntoClient
750752
@_unsafeInheritExecutor

stdlib/public/Concurrency/SourceCompatibilityShims.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public func withTaskCancellationHandler<T>(
6262
try await withTaskCancellationHandler(operation: operation, onCancel: handler)
6363
}
6464

65+
// Note: hack to stage out @_unsafeInheritExecutor forms of various functions
66+
// in favor of #isolation. The _unsafeInheritExecutor_ prefix is meaningful
67+
// to the type checker.
6568
@available(SwiftStdlib 5.1, *)
6669
@_alwaysEmitIntoClient
6770
@_unsafeInheritExecutor

stdlib/public/Concurrency/TaskCancellation.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ public func withTaskCancellationHandler<T>(
8282
return try await operation()
8383
}
8484

85+
// Note: hack to stage out @_unsafeInheritExecutor forms of various functions
86+
// in favor of #isolation. The _unsafeInheritExecutor_ prefix is meaningful
87+
// to the type checker.
88+
//
89+
// This function also doubles as an ABI-compatibility shim predating the
90+
// introduction of #isolation.
8591
@_unsafeInheritExecutor // ABI compatibility with Swift 5.1
8692
@available(SwiftStdlib 5.1, *)
8793
@_silgen_name("$ss27withTaskCancellationHandler9operation8onCancelxxyYaKXE_yyYbXEtYaKlF")

test/Concurrency/unsafe_inherit_executor.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ func unsafeCallerA(x: Int) async {
5353

5454
await inheritsIsolationProperly()
5555
// expected-error@-1{{#isolation (introduced by a default argument) cannot be used within an '@_unsafeInheritExecutor' function}}{{50:1-24=}}{{51:26-26=, isolation: isolated (any Actor)? = #isolation}}
56-
t 6)
5756
}
5857

5958
@_unsafeInheritExecutor

0 commit comments

Comments
 (0)