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
Copy file name to clipboardExpand all lines: test/Concurrency/sendable_checking.swift
+12Lines changed: 12 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,7 @@
4
4
5
5
@available(SwiftStdlib 5.1,*)
6
6
structNS1{}
7
+
// expected-note@-1 2{{consider making struct 'NS1' conform to the 'Sendable' protocol}}
7
8
8
9
@available(SwiftStdlib 5.1,*)
9
10
@available(*, unavailable)
@@ -68,10 +69,21 @@ public protocol MyProto {
68
69
func foo<F>(aFoo:F)asyncwhere F:Sendable
69
70
}
70
71
72
+
@available(SwiftStdlib 5.1,*)
73
+
func nonisolatedAsyncFunc1(_:NS1)async{}
74
+
75
+
@available(SwiftStdlib 5.1,*)
76
+
func nonisolatedAsyncFunc2()async->NS1{NS1()}
77
+
71
78
@available(SwiftStdlib 5.1,*)
72
79
publicactorMyActor:MyProto{
73
80
publicfunc foo<F>(aFoo:F)asyncwhere F:Sendable{}
74
81
publicfunc bar<B>(aBar:B)asyncwhere B:Sendable{}
82
+
83
+
func g(ns1:NS1)async{
84
+
awaitnonisolatedAsyncFunc1(ns1) // expected-warning{{non-sendable type 'NS1' exiting actor-isolated context in call to non-isolated global function 'nonisolatedAsyncFunc1' cannot cross actor boundary}}
85
+
_ =awaitnonisolatedAsyncFunc2() // expected-warning{{non-sendable type 'NS1' returned by call from actor-isolated context to non-isolated global function 'nonisolatedAsyncFunc2()' cannot cross actor boundary}}
86
+
}
75
87
}
76
88
77
89
// rdar://82452688 - make sure sendable checking doesn't fire for a capture
// This should not be diagnosed when we implement SE-0338 checking.
34
+
// expected-warning@+1{{non-sendable type 'NonSendableObject' exiting actor-isolated context in call to non-isolated global function 'useNonSendable(object:)' cannot cross actor boundary}}
0 commit comments