You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Emit Sendable diagnostics in actor-like deinits only in 'complete' checking mode (#59471)
The flow-isolation pass was not respecting the new strict-concurrency checking mode.
Since the Sendable diagnostics in these deinits are very noisy, I'm moving them to only
be emitted in 'complete' mode. The reason why they're so noisy is that any class that
inherits from a `@MainActor`-constrained class will have these diagnostics emitted when
trying to access its own `@MainActor`-isolated members.
This is needed, even during the `deinit`, because multiple instances of a `@MainActor`-isolated
class might have stored properties that refer to the same state.
This change specifically avoids emitting these diagnostics even in 'targeted' mode because
I'd like to take more time to reconsider the ergonomics of these deinits.
resolves rdar://94699928
globalVar =self // expected-note {{after making a copy of 'self', only non-isolated properties of 'self' can be accessed from this init}}
527
+
// expected-note@+2 {{after making a copy of 'self', only non-isolated properties of 'self' can be accessed from this init}}
528
+
// expected-warning@+1 {{reference to var 'globalVar' is not concurrency-safe because it involves shared mutable state}}
529
+
globalVar =self
530
+
531
+
// expected-warning@+1 {{reference to var 'globalVar' is not concurrency-safe because it involves shared mutable state}}
527
532
Task{await globalVar!.isolatedMethod()}
528
533
529
534
ifself.x ==0{ // expected-warning {{cannot access property 'x' here in non-isolated initializer; this is an error in Swift 6}}
@@ -700,3 +705,24 @@ actor OhBrother {
700
705
whatever =2 // expected-warning {{cannot access property 'whatever' here in non-isolated initializer; this is an error in Swift 6}}
701
706
}
702
707
}
708
+
709
+
@available(SwiftStdlib 5.1,*)
710
+
@MainActorclassAwesomeUIView{}
711
+
712
+
@available(SwiftStdlib 5.1,*)
713
+
classCheckDeinitFromClass:AwesomeUIView{
714
+
varns:NonSendableType?
715
+
deinit{
716
+
ns?.f() // expected-warning {{cannot access property 'ns' with a non-sendable type 'NonSendableType?' from non-isolated deinit; this is an error in Swift 6}}
717
+
ns =nil // expected-warning {{cannot access property 'ns' with a non-sendable type 'NonSendableType?' from non-isolated deinit; this is an error in Swift 6}}
718
+
}
719
+
}
720
+
721
+
@available(SwiftStdlib 5.1,*)
722
+
actorCheckDeinitFromActor{
723
+
varns:NonSendableType?
724
+
deinit{
725
+
ns?.f() // expected-warning {{cannot access property 'ns' with a non-sendable type 'NonSendableType?' from non-isolated deinit; this is an error in Swift 6}}
726
+
ns =nil // expected-warning {{cannot access property 'ns' with a non-sendable type 'NonSendableType?' from non-isolated deinit; this is an error in Swift 6}}
0 commit comments