-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[sema] Work around a double curry thunk actor isolation inference bug that is a knock on effect of ced96aa5cd653f834d2a8293ead8cf46649202cb. #82375
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// RUN: %target-swift-frontend -typecheck -strict-concurrency=complete -target %target-swift-5.1-abi-triple %s | ||
|
||
// REQUIRES: concurrency | ||
|
||
// We used to crash on this when processing double curry thunks. Make sure that | ||
// we do not do crash in the future. | ||
extension AsyncStream { | ||
@Sendable func myCancel() { | ||
} | ||
func myNext2(_ continuation: UnsafeContinuation<Element?, Never>) { | ||
} | ||
func myNext() async -> Element? { | ||
await withTaskCancellationHandler { | ||
unsafe await withUnsafeContinuation { | ||
unsafe myNext2($0) | ||
} | ||
} onCancel: { [myCancel] in | ||
myCancel() | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -338,3 +338,22 @@ func localCaptureDataRace5() { | |
|
||
x = 2 // expected-tns-note {{access can happen concurrently}} | ||
} | ||
|
||
func inferLocationOfCapturedActorIsolatedSelfCorrectly() { | ||
class A { | ||
var block: @MainActor () -> Void = {} | ||
} | ||
@CustomActor | ||
class B { | ||
let a = A() | ||
|
||
func d() { | ||
a.block = c // expected-warning {{converting non-Sendable function value to '@MainActor @Sendable () -> Void' may introduce data races}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the new checks are handling optionals explicitly, let's add a few test cases that have different levels optionality to make sure that works correctly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added the optional check b/c I was hitting it in the test suite. But I can add an actual test. |
||
// expected-warning @-1 {{non-Sendable '@MainActor () -> ()'-typed result can not be returned from main actor-isolated function to global actor 'CustomActor'-isolated context}} | ||
// expected-note @-2 {{a function type must be marked '@Sendable' to conform to 'Sendable'}} | ||
} | ||
|
||
@MainActor | ||
func c() {} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need a comment explaining why we are doing this here and what the alternatives are.