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(
5490
5490
5491
5491
// / Handle a stored property.
5492
5492
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
+
5493
5501
// Classes with mutable properties are Sendable if property is
5494
5502
// actor-isolated
5495
5503
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 ()) {
5500
5505
auto behavior =
5501
5506
SendableCheckContext (dc, check).defaultDiagnosticBehavior ();
5502
5507
if (behavior != DiagnosticBehavior::Ignore) {
Original file line number Diff line number Diff line change @@ -361,3 +361,10 @@ enum SynthesizedConformances {
361
361
let x : NotSendable
362
362
}
363
363
}
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