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
[TypeChecker] Remove @_inheritActorContext effect from synchronous types
The compiler would previously accept use of `@_inheritActorContext`
on a parameter with a synchronous function type which wasn't marked
as `@isolated(any)`. That is incorrect because in such cases the
attribute has no effect and furthermore would prevent Sendable
and isolation checking.
Uses like that are currently diagnosed by the type-checker but we
need to go one step further and remove the effect in such case to
prevent invalid uses.
Resolves: rdar://143581268
// expected-warning@-1 {{@_inheritActorContext only applies to '@isolated(any)' parameters or parameters with asynchronous function types; this will be an error in a future Swift language mode}}
1758
+
1759
+
actorInvalidInheritedActorIsolation{
1760
+
func actorFunction(){} // expected-note {{calls to instance method 'actorFunction()' from outside of its actor context are implicitly asynchronous}}
1761
+
1762
+
func test(){
1763
+
requireSendableInheritContext{
1764
+
self.actorFunction()
1765
+
// expected-error@-1 {{call to actor-isolated instance method 'actorFunction()' in a synchronous nonisolated context}}
1766
+
}
1767
+
}
1768
+
}
1769
+
1770
+
@MainActor
1771
+
classInvalidInheritedGlobalActorIsolation{
1772
+
func mainActorFunction(){} // expected-note {{calls to instance method 'mainActorFunction()' from outside of its actor context are implicitly asynchronous}}
1773
+
1774
+
func test(){
1775
+
requireSendableInheritContext{
1776
+
self.mainActorFunction()
1777
+
// expected-error@-1 {{call to main actor-isolated instance method 'mainActorFunction()' in a synchronous nonisolated context}}
// expected-warning@-1 {{@_inheritActorContext only applies to '@isolated(any)' parameters or parameters with asynchronous function types; this will be an error in a future Swift language mode}}
// expected-warning@-1 {{main actor-isolated property 'value' can not be referenced from a Sendable closure; this is an error in the Swift 6 language mode}}
0 commit comments