Skip to content

Commit 8e055e9

Browse files
committed
[region-isolation] Add a test case for a reported failure that I already fixed.
This is just to make sure that we do not break it again. rdar://128195659
1 parent 9f8e5e8 commit 8e055e9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/Concurrency/transfernonsendable.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class NonSendableKlass { // expected-complete-note 53{{}}
2626
func asyncCall() async {}
2727
func asyncCallWithIsolatedParameter(isolation: isolated (any Actor)? = #isolation) async {
2828
}
29+
30+
func getSendableGenericStructAsync() async -> SendableGenericStruct { fatalError() }
2931
}
3032

3133
class SendableKlass : @unchecked Sendable {}
@@ -82,6 +84,10 @@ class TwoFieldKlassClassBox {
8284
var recursive: TwoFieldKlassClassBox? = nil
8385
}
8486

87+
struct SendableGenericStruct : Sendable {
88+
var x = SendableKlass()
89+
}
90+
8591
////////////////////////////
8692
// MARK: Actor Self Tests //
8793
////////////////////////////
@@ -1811,6 +1817,16 @@ actor FunctionWithSendableResultAndIsolationActor {
18111817
}
18121818
}
18131819

1820+
// This was a test case that we used to emit an "pattern the compiler doesn't
1821+
// understand" error. We now accept it, so lets make sure we keep doing so!
1822+
@MainActor
1823+
func previouslyBrokenTestCase(ns: NonSendableKlass) async -> SendableGenericStruct? {
1824+
return await { () -> SendableGenericStruct? in
1825+
return await ns.getSendableGenericStructAsync() // expected-warning {{sending 'ns' risks causing data races}}
1826+
// expected-note @-1 {{sending main actor-isolated 'ns' to nonisolated instance method 'getSendableGenericStructAsync()' risks causing data races between nonisolated and main actor-isolated uses}}
1827+
}()
1828+
}
1829+
18141830
@MainActor
18151831
func testThatGlobalActorTakesPrecedenceOverActorIsolationOnMethods() async {
18161832
let a = MyActor()

0 commit comments

Comments
 (0)