File tree 2 files changed +16
-0
lines changed
test/Concurrency/attr_execution
2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -4681,6 +4681,10 @@ ActorIsolation ActorIsolationChecker::determineClosureIsolation(
4681
4681
attr && ctx.LangOpts .hasFeature (Feature::ClosureIsolation)) {
4682
4682
return ActorIsolation::forNonisolated (attr->isUnsafe ());
4683
4683
}
4684
+
4685
+ if (explicitClosure->getAttrs ().hasAttribute <ConcurrentAttr>()) {
4686
+ return ActorIsolation::forNonisolated (/* unsafe=*/ false );
4687
+ }
4684
4688
}
4685
4689
4686
4690
// `nonisolated(nonsending)` inferred from the context makes
Original file line number Diff line number Diff line change @@ -456,3 +456,15 @@ func testThatClosuresAssumeIsolation(fn: inout nonisolated(nonsending) (Int) asy
456
456
// CHECK: hop_to_executor [[GENERIC_EXECUTOR]]
457
457
fn = { @concurrent _ in }
458
458
}
459
+
460
+ @MainActor
461
+ func testNoIsolationTransfer( ) {
462
+ // CHECK: // Isolation: global_actor. type: MainActor
463
+ // CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen23testNoIsolationTransferyyF0D7ErasureL_yyyyYaYAcF : $@convention(thin) (@guaranteed @isolated(any) @async @callee_guaranteed () -> ()) -> ()
464
+ func testErasure( @_inheritActorContext _: @escaping @isolated ( any) ( ) async -> Void ) { }
465
+
466
+ // CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen23testNoIsolationTransferyyFyyYacfU_ : $@convention(thin) @async (@guaranteed Optional<any Actor>) -> ()
467
+ // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional<Builtin.Executor>, #Optional.none!enumelt
468
+ // CHECK: hop_to_executor [[GENERIC_EXECUTOR]]
469
+ testErasure { @concurrent in }
470
+ }
You can’t perform that action at this time.
0 commit comments