Skip to content

[region-isolation] Add a test case for a reported failure that I already fixed. #75078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/Concurrency/transfernonsendable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class NonSendableKlass { // expected-complete-note 53{{}}
func asyncCall() async {}
func asyncCallWithIsolatedParameter(isolation: isolated (any Actor)? = #isolation) async {
}

func getSendableGenericStructAsync() async -> SendableGenericStruct { fatalError() }
}

class SendableKlass : @unchecked Sendable {}
Expand Down Expand Up @@ -83,6 +85,10 @@ class TwoFieldKlassClassBox {
var recursive: TwoFieldKlassClassBox? = nil
}

struct SendableGenericStruct : Sendable {
var x = SendableKlass()
}

////////////////////////////
// MARK: Actor Self Tests //
////////////////////////////
Expand Down Expand Up @@ -1812,6 +1818,16 @@ actor FunctionWithSendableResultAndIsolationActor {
}
}

// This was a test case that we used to emit an "pattern the compiler doesn't
// understand" error. We now accept it, so lets make sure we keep doing so!
@MainActor
func previouslyBrokenTestCase(ns: NonSendableKlass) async -> SendableGenericStruct? {
return await { () -> SendableGenericStruct? in
return await ns.getSendableGenericStructAsync() // expected-tns-warning {{sending 'ns' risks causing data races}}
// 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}}
}()
}

@MainActor
func testThatGlobalActorTakesPrecedenceOverActorIsolationOnMethods() async {
let a = MyActor()
Expand Down