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
// warning goes away with InferSendableFromCaptures, see actor_isolation_swift6.swift
1735
+
return functionRef // expected-warning {{converting non-sendable function value to '@MainActor @Sendable () -> Void' may introduce data races}}
1736
+
}
1737
+
1738
+
@MainActor
1739
+
privatefunc callOnMainActorOk(){
1740
+
letmainActorAffinedClosure=testCurry()(self)
1741
+
mainActorAffinedClosure()
1742
+
}
1743
+
1744
+
nonisolated
1745
+
privatefunc nonisolatedCallErrors(){
1746
+
letmainActorAffinedClosure=testCurry()(self)
1747
+
// expected-note@-1 {{calls to let 'mainActorAffinedClosure' from outside of its actor context are implicitly asynchronous}}
1748
+
mainActorAffinedClosure()
1749
+
// expected-error@-1 {{call to main actor-isolated let 'mainActorAffinedClosure' in a synchronous nonisolated context}}
1750
+
}
1751
+
}
1752
+
1753
+
actorUserDefinedActorSelfDotMethod{
1754
+
func actorAffinedFunc(){} // expected-note {{calls to instance method 'actorAffinedFunc()' from outside of its actor context are implicitly asynchronous}}
1755
+
1756
+
// Unfortunately we can't express the desired isolation of this returned closure statically to
1757
+
// be able to call it on the desired actor. This may be possible with the acceptance of
1758
+
// https://forums.swift.org/t/closure-isolation-control/70378 but I think we need more expressivity
1759
+
// in the type system to express this sort of curry.
letfunctionRef=Self.actorAffinedFunc // expected-error {{call to actor-isolated instance method 'actorAffinedFunc()' in a synchronous nonisolated context}}
1763
+
// error message changes with InferSendabaleFromCaptures - see actor_isolation_swift6.swift
1764
+
return functionRef // expected-error {{cannot convert return expression of type '(isolated Self) -> () -> ()' to return type '(UserDefinedActorSelfDotMethod) -> @isolated(any) () -> Void'}}
// expected-note@-1 {{calls to let 'mainActorAffinedClosure' from outside of its actor context are implicitly asynchronous}}
119
+
mainActorAffinedClosure()
120
+
// expected-error@-1 {{call to main actor-isolated let 'mainActorAffinedClosure' in a synchronous nonisolated context}}
121
+
}
122
+
}
123
+
124
+
actorUserDefinedActorSelfDotMethod{
125
+
func actorAffinedFunc(){} // expected-note {{calls to instance method 'actorAffinedFunc()' from outside of its actor context are implicitly asynchronous}}
126
+
127
+
// Unfortunately we can't express the desired isolation of this returned closure statically to
128
+
// be able to call it on the desired actor. This may be possible with the acceptance of
129
+
// https://forums.swift.org/t/closure-isolation-control/70378 but I think we need more expressivity
130
+
// in the type system to express this sort of curry.
letfunctionRef=Self.actorAffinedFunc // expected-error {{call to actor-isolated instance method 'actorAffinedFunc()' in a synchronous nonisolated context}}
134
+
return functionRef // expected-error {{cannot convert return expression of type '@Sendable (isolated Self) -> @Sendable () -> ()' to return type '(UserDefinedActorSelfDotMethod) -> @isolated(any) () -> Void'}}
0 commit comments