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
[Concurrency] Handle cases where a property initializer is subsumed by another
property for IsolatedDefaultValues.
For property wrappers and init accesors, skip property initializers that are
subsumed, e.g. by an init accessor or a backing property wrapper initializer,
and always consider the subsuming initializer to determine whether compiler
synthesized initializers should have `nonisolated` applied.
This change also lessens the source break of SE-0411 by still emitting
member initializers in implicit constructors when the initializer violates
actor isolation to preserve the behavior of existing code when concurrency
diagnostics are downgraded to warnings in Swift 5 mode.
(cherry picked from commit 20829fa)
// check for instance members that do not need global-actor protection
171
+
172
+
// expected-warning@+2 {{memberwise initializer for 'NoGlobalActorValueType' cannot be both nonisolated and global actor 'SomeGlobalActor'-isolated; this is an error in Swift 6}}
171
173
// expected-note@+1 2 {{consider making struct 'NoGlobalActorValueType' conform to the 'Sendable' protocol}}
172
174
structNoGlobalActorValueType{
173
175
@SomeGlobalActorvarpoint:Point // expected-warning {{stored property 'point' within struct cannot have a global actor; this is an error in Swift 6}}
176
+
// expected-note@-1 {{initializer for property 'point' is global actor 'SomeGlobalActor'-isolated}}
174
177
175
178
@MainActorletcounter:Int // expected-warning {{stored property 'counter' within struct cannot have a global actor; this is an error in Swift 6}}
// HasWrapperOnUnsafeActor gets an inferred @MainActor attribute.
561
+
// HasWrapperOnUnsafeActor does not have an inferred global actor attribute,
562
+
// because synced and $synced have different global actors.
562
563
structHasWrapperOnUnsafeActor{
563
-
@WrapperOnUnsafeActorvarsynced:Int=0 // expected-complete-sns-warning {{global actor 'OtherGlobalActor'-isolated default value in a main actor-isolated context; this is an error in Swift 6}}
564
+
// expected-complete-sns-warning@-1 {{memberwise initializer for 'HasWrapperOnUnsafeActor' cannot be both nonisolated and global actor 'OtherGlobalActor'-isolated; this is an error in Swift 6}}
565
+
// expected-complete-sns-warning@-2 {{default initializer for 'HasWrapperOnUnsafeActor' cannot be both nonisolated and global actor 'OtherGlobalActor'-isolated; this is an error in Swift 6}}
566
+
567
+
@WrapperOnUnsafeActorvarsynced:Int=0 // expected-complete-sns-note 2 {{initializer for property '_synced' is global actor 'OtherGlobalActor'-isolated}}
// expected-complete-sns-warning@+1 {{default initializer for 'Cutter' cannot be both nonisolated and main actor-isolated; this is an error in Swift 6}}
672
681
classCutter{
682
+
// expected-complete-sns-note@+1 {{initializer for property 'x' is main actor-isolated}}
0 commit comments