Skip to content

Commit 425b805

Browse files
committed
[Concurrency] Don't diagnose 'nonisolated(unsafe)' properties during flow isolation.
1 parent 39c7962 commit 425b805

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,9 @@ static bool varIsSafeAcrossActors(const ModuleDecl *fromModule,
507507
bool accessWithinModule =
508508
(fromModule == var->getDeclContext()->getParentModule());
509509

510+
if (varIsolation.getKind() == ActorIsolation::NonisolatedUnsafe)
511+
return true;
512+
510513
if (!var->isLet()) {
511514
ASTContext &ctx = var->getASTContext();
512515
if (ctx.LangOpts.hasFeature(Feature::GlobalActorIsolatedTypesUsability)) {

test/Concurrency/flow_isolation.swift

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// RUN: %target-swift-frontend -strict-concurrency=complete -swift-version 5 -parse-as-library -emit-sil -verify %s
22
// RUN: %target-swift-frontend -strict-concurrency=complete -swift-version 5 -parse-as-library -emit-sil -verify %s -enable-upcoming-feature RegionBasedIsolation
33

4-
// REQUIRES: asserts
5-
64
func randomBool() -> Bool { return false }
75
func logTransaction(_ i: Int) {}
86

@@ -815,3 +813,20 @@ func testActorWithInitAccessorInit() {
815813
}
816814
}
817815
}
816+
817+
@available(SwiftStdlib 5.1, *)
818+
actor TestNonisolatedUnsafe {
819+
private nonisolated(unsafe) var child: OtherActor!
820+
init() {
821+
child = OtherActor(parent: self)
822+
}
823+
}
824+
825+
@available(SwiftStdlib 5.1, *)
826+
actor OtherActor {
827+
unowned nonisolated let parent: any Actor
828+
829+
init(parent: any Actor) {
830+
self.parent = parent
831+
}
832+
}

0 commit comments

Comments
 (0)