Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/Sema/TypeCheckConcurrency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4699,6 +4699,10 @@ ActorIsolation ActorIsolationChecker::determineClosureIsolation(
attr && ctx.LangOpts.hasFeature(Feature::ClosureIsolation)) {
return ActorIsolation::forNonisolated(attr->isUnsafe());
}

if (explicitClosure->getAttrs().hasAttribute<ConcurrentAttr>()) {
return ActorIsolation::forNonisolated(/*unsafe=*/false);
}
}

// `nonisolated(nonsending)` inferred from the context makes
Expand Down
12 changes: 12 additions & 0 deletions test/Concurrency/attr_execution/conversions_silgen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,15 @@ func testThatClosuresAssumeIsolation(fn: inout nonisolated(nonsending) (Int) asy
// CHECK: hop_to_executor [[GENERIC_EXECUTOR]]
fn = { @concurrent _ in }
}

@MainActor
func testNoIsolationTransfer() {
// CHECK: // Isolation: global_actor. type: MainActor
// CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen23testNoIsolationTransferyyF0D7ErasureL_yyyyYaYAcF : $@convention(thin) (@guaranteed @isolated(any) @async @callee_guaranteed () -> ()) -> ()
func testErasure(@_inheritActorContext _: @escaping @isolated(any) () async -> Void) {}

// CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen23testNoIsolationTransferyyFyyYacfU_ : $@convention(thin) @async (@guaranteed Optional<any Actor>) -> ()
// CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional<Builtin.Executor>, #Optional.none!enumelt
// CHECK: hop_to_executor [[GENERIC_EXECUTOR]]
testErasure { @concurrent in }
}