Skip to content

Conversation

@gottesmm
Copy link
Contributor

This is important to ensure that we require the base of src if the src is non-Sendable (e.x.: a non-Sendable box).

rdar://163322459
#85107

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add tests for the other cases mentioned in the report, for completeness? <T: AnyObject & Sendable>, and an AnyObject existential

// expected-ni-ns-note @-2 {{sending task-isolated 'x' to @concurrent global function 'useValueAsyncConcurrent' risks causing data races between @concurrent and task-isolated uses}}
}

enum RequireSrcWhenStoringEvenWhenSendable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any chance the solution here can be extended to address this case as well:

// https://github.com/swiftlang/swift/issues/82827
@MainActor
func test_82827() {
    var s = 1
    Task {
        for _ in 0..<100 {
            s += 1
        }
    }
    Task.detached { _ = s } // not diagnosed
}

or is that a separate problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a separate problem. I took a quick look and we are at least not assuming that placing the non-Sendable box into the first Task makes it MainActor isolated. I would need to look further to find the fix. But it isn't this.

@gottesmm gottesmm force-pushed the pr-39de26ee629693f844665c42d2bdff56838838a0 branch from 3f180c6 to 05df552 Compare November 3, 2025 20:56
@gottesmm
Copy link
Contributor Author

gottesmm commented Nov 3, 2025

@swift-ci smoke test

@gottesmm
Copy link
Contributor Author

gottesmm commented Nov 4, 2025

We are emitting an error on this now:

private func runAsync<T: Sendable>(_ body: @escaping @Sendable () async throws -> T) throws -> T {
  var result: Result<T, Error>!
  Task {
    do {
      result = .success(try await body())
    } catch {
      result = .failure(error)
    }
  }
  return try result.get()
}

@gottesmm
Copy link
Contributor Author

gottesmm commented Nov 4, 2025

swiftlang/sourcekit-lsp#2348

@swift-ci smoke test

…value being stored is Sendable

This is important to ensure that we require the base of src if the src is
non-Sendable (e.x.: a non-Sendable box).

rdar://163322459
swiftlang#85107
@gottesmm gottesmm disabled auto-merge November 5, 2025 21:01
@gottesmm gottesmm force-pushed the pr-39de26ee629693f844665c42d2bdff56838838a0 branch from 05df552 to f0a4571 Compare November 5, 2025 21:01
@gottesmm
Copy link
Contributor Author

gottesmm commented Nov 5, 2025

swiftlang/sourcekit-lsp#2348

@swift-ci smoke test

@gottesmm
Copy link
Contributor Author

gottesmm commented Nov 6, 2025

swiftlang/sourcekit-lsp#2348

@swift-ci smoke test macOS platform

@gottesmm gottesmm merged commit 59e1474 into swiftlang:main Nov 7, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants