File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -5490,13 +5490,18 @@ static bool checkSendableInstanceStorage(
54905490
54915491 // / Handle a stored property.
54925492 bool operator ()(VarDecl *property, Type propertyType) override {
5493+ ActorIsolation isolation = getActorIsolation (property);
5494+
5495+ // 'nonisolated' properties are always okay in 'Sendable' types because
5496+ // they can be accessed from anywhere. Note that 'nonisolated' without
5497+ // '(unsafe)' can only be applied to immutable, 'Sendable' properties.
5498+ if (isolation.isNonisolated ())
5499+ return false ;
5500+
54935501 // Classes with mutable properties are Sendable if property is
54945502 // actor-isolated
54955503 if (isa<ClassDecl>(nominal)) {
5496- ActorIsolation isolation = getActorIsolation (property);
5497-
5498- if (property->supportsMutation () &&
5499- (isolation.isNonisolated () || isolation.isUnspecified ())) {
5504+ if (property->supportsMutation () && isolation.isUnspecified ()) {
55005505 auto behavior =
55015506 SendableCheckContext (dc, check).defaultDiagnosticBehavior ();
55025507 if (behavior != DiagnosticBehavior::Ignore) {
Original file line number Diff line number Diff line change @@ -361,3 +361,10 @@ enum SynthesizedConformances {
361361 let x : NotSendable
362362 }
363363}
364+
365+ @available ( SwiftStdlib 5 . 1 , * )
366+ final class UseNonisolatedUnsafe : Sendable {
367+ nonisolated ( unsafe) var x1 : NonSendable = . init( )
368+ nonisolated ( unsafe) let x2 : NonSendable = . init( )
369+ nonisolated ( unsafe) var x3 : Int = 0
370+ }
You can’t perform that action at this time.
0 commit comments