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(
52195219
52205220 // / Handle a stored property.
52215221 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
52235223 // actor-isolated
5224- if (property-> supportsMutation () && isa<ClassDecl>(nominal)) {
5224+ if (isa<ClassDecl>(nominal)) {
52255225 ActorIsolation isolation = getActorIsolation (property);
52265226
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 ())) {
52345229 auto behavior =
52355230 SendableCheckContext (dc, check).defaultDiagnosticBehavior ();
52365231 if (behavior != DiagnosticBehavior::Ignore) {
@@ -5242,6 +5237,10 @@ static bool checkSendableInstanceStorage(
52425237 invalid = invalid || (behavior == DiagnosticBehavior::Unspecified);
52435238 return true ;
52445239 }
5240+
5241+ if (!(isolation.isNonisolated () || isolation.isUnspecified ())) {
5242+ return false ; // skip sendable check on actor-isolated properties
5243+ }
52455244 }
52465245
52475246 // 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
343343
344344@globalActor
345345struct SomeActor {
346- static var shared = A1 ( )
346+ static let shared = A1 ( )
347347}
348+
349+ class NotSendable { }
350+
348351// actor-isolated mutable properties are valid
349352final class C10 : Sendable {
350353 @MainActor var x = 0
351- @SomeActor var y = 1
354+ @MainActor var ns1 : NotSendable ?
355+ @MainActor let ns : NotSendable ? = nil
352356}
353357
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 ( )
357362}
358363
359364extension NotConcurrent {
You can’t perform that action at this time.
0 commit comments