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
// 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}}
// expected-error@+1 {{default argument cannot be both main actor-isolated and global actor 'SomeGlobalActor'-isolated}}
152
+
// expected-error@+1 3 {{default argument cannot be both main actor-isolated and global actor 'SomeGlobalActor'-isolated}}
155
153
var(x, y, z)=(requiresMainActor(),requiresSomeGlobalActor(),10)
156
154
}
157
155
@@ -196,21 +194,19 @@ extension A {
196
194
}
197
195
}
198
196
199
-
// expected-error@+1 {{default initializer for 'C1' cannot be both main actor-isolated and global actor 'SomeGlobalActor'-isolated}}
197
+
// expected-warning@+1 {{default initializer for 'C1' cannot be both nonisolated and main actor-isolated; this is an error in Swift 6}}
200
198
classC1{
201
199
// expected-note@+1 {{initializer for property 'x' is main actor-isolated}}
202
200
@MainActorvarx=requiresMainActor()
203
-
// expected-note@+1 {{initializer for property 'y' is global actor 'SomeGlobalActor'-isolated}}
204
201
@SomeGlobalActorvary=requiresSomeGlobalActor()
205
202
}
206
203
207
204
classNonSendable{}
208
205
209
-
// expected-error@+1 {{default initializer for 'C2' cannot be both main actor-isolated and global actor 'SomeGlobalActor'-isolated}}
206
+
// expected-warning@+1 {{default initializer for 'C2' cannot be both nonisolated and main actor-isolated; this is an error in Swift 6}}
210
207
classC2{
211
208
// expected-note@+1 {{initializer for property 'x' is main actor-isolated}}
212
209
@MainActorvarx=NonSendable()
213
-
// expected-note@+1 {{initializer for property 'y' is global actor 'SomeGlobalActor'-isolated}}
214
210
@SomeGlobalActorvary=NonSendable()
215
211
}
216
212
@@ -224,8 +220,65 @@ class C3 {
224
220
vary=0
225
221
}
226
222
223
+
@MainActorclassMultipleVars{
224
+
var(x, y)=(0,0)
225
+
}
226
+
227
227
func callDefaultInit()async{
228
228
_ =C2()
229
229
_ =NonIsolatedInit()
230
230
_ =NonIsolatedInit(x:10)
231
+
_ =MultipleVars()
232
+
}
233
+
234
+
// expected-warning@+1 {{default initializer for 'MultipleVarsInvalid' cannot be both nonisolated and main actor-isolated; this is an error in Swift 6}}
235
+
classMultipleVarsInvalid{
236
+
// expected-note@+1 {{initializer for property 'x' is main actor-isolated}}
0 commit comments