Skip to content

Commit b8dc0f1

Browse files
authored
Merge pull request #75078 from gottesmm/pr-3029a4876a9727da1801fc26d959277ac9aecc3d
[region-isolation] Add a test case for a reported failure that I already fixed.
2 parents f222312 + 4b9e9a5 commit b8dc0f1

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
@@ -27,6 +27,8 @@ class NonSendableKlass { // expected-complete-note 53{{}}
2727
func asyncCall() async {}
2828
func asyncCallWithIsolatedParameter(isolation: isolated (any Actor)? = #isolation) async {
2929
}
30+
31+
func getSendableGenericStructAsync() async -> SendableGenericStruct { fatalError() }
3032
}
3133

3234
class SendableKlass : @unchecked Sendable {}
@@ -83,6 +85,10 @@ class TwoFieldKlassClassBox {
8385
var recursive: TwoFieldKlassClassBox? = nil
8486
}
8587

88+
struct SendableGenericStruct : Sendable {
89+
var x = SendableKlass()
90+
}
91+
8692
////////////////////////////
8793
// MARK: Actor Self Tests //
8894
////////////////////////////
@@ -1812,6 +1818,16 @@ actor FunctionWithSendableResultAndIsolationActor {
18121818
}
18131819
}
18141820

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

0 commit comments

Comments
 (0)