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
have the inferred isolation for properties change only in Swift 6
This patch delays the removal of redundant isolation for inferred
global-actor isolation to Swift 6 too, since we only warn about it
changing in Swift 5. Otherwise, only isolation that is a byproduct
of inference no longer needs an await, which will probably confuse
people.
This change is with respect to SE-327, which argues that the
non-static stored properties of ordinary structs do not need
global-actor isolation.
// these do not need an await, since it's a value type
152
-
_ = ext.point
153
-
_ = formance.counter
154
-
_ = anno.point
146
+
// these still do need an await in Swift 5
147
+
_ =awaitext.point // expected-warning {{non-sendable type 'Point' in implicitly asynchronous access to main actor-isolated property 'point' cannot cross actor boundary}}
148
+
_ =awaitformance.counter
149
+
_ =awaitanno.point // expected-warning {{non-sendable type 'Point' in implicitly asynchronous access to global actor 'SomeGlobalActor'-isolated property 'point' cannot cross actor boundary}}
155
150
_ = anno.counter
156
151
157
-
// make sure it's just a warning if someone was awaiting on it previously
_ = thing // expected-error {{property 'thing' isolated to global actor 'MainActor' can not be referenced from a non-isolated synchronous context}}
364
-
_ = _thing.wrappedValue // expected-error {{property 'wrappedValue' isolated to global actor 'MainActor' can not be referenced from a non-isolated synchronous context}}
365
-
366
-
_ = _thing
367
-
_ = _thing.accessCount
368
-
369
-
_ = plainStorage
370
-
371
-
_ = computedProp // expected-error {{property 'computedProp' isolated to global actor 'MainActor' can not be referenced from a non-isolated synchronous context}}
372
-
}
373
-
}
374
-
375
355
structHasWrapperOnActor{
376
356
@WrapperOnActorvarsynced:Int=0
377
-
// expected-note@-1 2{{property declared here}}
357
+
// expected-note@-1 3{{property declared here}}
378
358
379
359
// expected-note@+1 3{{to make instance method 'testErrors()'}}
380
360
func testErrors(){
381
361
_ = synced // expected-error{{property 'synced' isolated to global actor 'MainActor' can not be referenced from this synchronous context}}
382
362
_ = $synced // expected-error{{property '$synced' isolated to global actor 'SomeGlobalActor' can not be referenced from this synchronous context}}
383
-
_ = _synced
384
-
_ = _synced.wrappedValue // expected-error{{property 'wrappedValue' isolated to global actor 'MainActor' can not be referenced from this synchronous context}}
363
+
_ = _synced // expected-error{{property '_synced' isolated to global actor 'OtherGlobalActor' can not be referenced from this synchronous context}}
_ = synced // expected-error{{property 'synced' isolated to global actor 'MainActor' can not be referenced from}}
553
532
_ = $synced // expected-error{{property '$synced' isolated to global actor 'SomeGlobalActor' can not be referenced from}}
554
-
_ = _synced
533
+
_ = _synced // expected-error{{property '_synced' isolated to global actor 'OtherGlobalActor' can not be referenced from a non-isolated synchronous context}}
_ = thing // expected-error {{property 'thing' isolated to global actor 'MainActor' can not be referenced from a non-isolated synchronous context}}
84
+
_ = _thing.wrappedValue // expected-error {{property 'wrappedValue' isolated to global actor 'MainActor' can not be referenced from a non-isolated synchronous context}}
85
+
86
+
_ = _thing
87
+
_ = _thing.accessCount
88
+
89
+
_ = plainStorage
90
+
91
+
_ = computedProp // expected-error {{property 'computedProp' isolated to global actor 'MainActor' can not be referenced from a non-isolated synchronous context}}
92
+
}
93
+
}
94
+
95
+
structHasWrapperOnActor{
96
+
@WrapperOnActorvarsynced:Int=0
97
+
// expected-note@-1 2{{property declared here}}
98
+
99
+
// expected-note@+1 3{{to make instance method 'testErrors()'}}
100
+
func testErrors(){
101
+
_ = synced // expected-error{{property 'synced' isolated to global actor 'MainActor' can not be referenced from this synchronous context}}
102
+
_ = $synced // expected-error{{property '$synced' isolated to global actor 'SomeGlobalActor' can not be referenced from this synchronous context}}
103
+
_ = _synced
104
+
_ = _synced.wrappedValue // expected-error{{property 'wrappedValue' isolated to global actor 'MainActor' can not be referenced from this synchronous context}}
return atomicWeight // expected-error {{property 'atomicWeight' isolated to global actor 'MainActor' can not be referenced from a non-isolated synchronous context}}
0 commit comments