File tree Expand file tree Collapse file tree 2 files changed +18
-14
lines changed Expand file tree Collapse file tree 2 files changed +18
-14
lines changed Original file line number Diff line number Diff line change @@ -5219,18 +5219,13 @@ static bool checkSendableInstanceStorage(
5219
5219
5220
5220
// / Handle a stored property.
5221
5221
bool operator ()(VarDecl *property, Type propertyType) override {
5222
- // Classes with mutable properties are not Sendable unless property is
5222
+ // Classes with mutable properties are Sendable if property is
5223
5223
// actor-isolated
5224
- if (property-> supportsMutation () && isa<ClassDecl>(nominal)) {
5224
+ if (isa<ClassDecl>(nominal)) {
5225
5225
ActorIsolation isolation = getActorIsolation (property);
5226
5226
5227
- if (isolation.getKind () == ActorIsolation::Kind::Nonisolated ||
5228
- isolation.getKind () == ActorIsolation::Kind::Unspecified) {
5229
- if (isImplicitSendableCheck (check)) {
5230
- invalid = true ;
5231
- return true ;
5232
- }
5233
-
5227
+ if (property->supportsMutation () &&
5228
+ (isolation.isNonisolated () || isolation.isUnspecified ())) {
5234
5229
auto behavior =
5235
5230
SendableCheckContext (dc, check).defaultDiagnosticBehavior ();
5236
5231
if (behavior != DiagnosticBehavior::Ignore) {
@@ -5242,6 +5237,10 @@ static bool checkSendableInstanceStorage(
5242
5237
invalid = invalid || (behavior == DiagnosticBehavior::Unspecified);
5243
5238
return true ;
5244
5239
}
5240
+
5241
+ if (!(isolation.isNonisolated () || isolation.isUnspecified ())) {
5242
+ return false ; // skip sendable check on actor-isolated properties
5243
+ }
5245
5244
}
5246
5245
5247
5246
// Check that the property type is Sendable.
Original file line number Diff line number Diff line change @@ -343,17 +343,22 @@ class C9: Sendable { } // expected-warning{{non-final class 'C9' cannot conform
343
343
344
344
@globalActor
345
345
struct SomeActor {
346
- static var shared = A1 ( )
346
+ static let shared = A1 ( )
347
347
}
348
+
349
+ class NotSendable { }
350
+
348
351
// actor-isolated mutable properties are valid
349
352
final class C10 : Sendable {
350
353
@MainActor var x = 0
351
- @SomeActor var y = 1
354
+ @MainActor var ns1 : NotSendable ?
355
+ @MainActor let ns : NotSendable ? = nil
352
356
}
353
357
354
- // 'nonisolated (unsafe)' mutable properties are valid
355
- final class C13 : Sendable {
356
- nonisolated ( unsafe) var z = 2
358
+ final class C14 : Sendable {
359
+ @SomeActor var y = 1
360
+ @SomeActor var nc = NotConcurrent ( )
361
+ @SomeActor let nc1 = NotConcurrent ( )
357
362
}
358
363
359
364
extension NotConcurrent {
You can’t perform that action at this time.
0 commit comments