File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -965,6 +965,19 @@ SILIsolationInfo SILIsolationInfo::get(SILInstruction *inst) {
965965 }
966966 }
967967
968+ if (auto *bbi = dyn_cast<BeginBorrowInst>(inst)) {
969+ if (bbi->isFromVarDecl ()) {
970+ // See if we have the actual AST information on our instruction.
971+ if (auto *varDecl = bbi->getLoc ().getAsASTNode <VarDecl>()) {
972+ auto isolation = swift::getActorIsolation (varDecl);
973+ if (isolation.getKind () == ActorIsolation::NonisolatedUnsafe) {
974+ return SILIsolationInfo::getDisconnected (
975+ true /* is nonisolated(unsafe)*/ );
976+ }
977+ }
978+ }
979+ }
980+
968981 // / Consider non-Sendable metatypes to be task-isolated, so they cannot cross
969982 // / into another isolation domain.
970983 if (auto *mi = dyn_cast<MetatypeInst>(inst)) {
Original file line number Diff line number Diff line change @@ -329,6 +329,18 @@ func useAfterTransferLetSquelchedIndirectAddressOnly<T : ProvidesStaticValue>(_
329329 print ( ns4)
330330}
331331
332+ func testNonisolatedUnsafeForwardDeclaredVar< T: Sendable > ( _ body: @escaping @Sendable ( ) async throws -> T ) throws -> T {
333+ nonisolated ( unsafe) var result : Result < T , Error > !
334+ Task {
335+ do {
336+ result = . success( try await body ( ) )
337+ } catch {
338+ result = . failure( error)
339+ }
340+ }
341+ return try result. get ( )
342+ }
343+
332344////////////////////////
333345// MARK: Global Tests //
334346////////////////////////
You can’t perform that action at this time.
0 commit comments