Open yonihemi opened 1 month ago
I've run into a similar situation when awaiting an async var:
// ✅
// Breaking this up into 2 lines works around a Swift bug with region-based isolation checking
let staleTasks = await service.allTasks
try removeStaleBackgroundTasks(tasks: staleTasks)
// ❌
try await removeStaleBackgroundTasks(tasks: service.allTasks)
I've run into same issue in a bit different situation.
actor NotificationManagerr {
func scheduleTimeIntervalNotification() async throws {
// ❌ Pattern that the region based isolation checker does not understand how to check. Please file a bug
try await scheduleNotification()
// ✅
try await scheduleNotification(sound: .default)
}
private func scheduleNotification(
sound: UNNotificationSound = .default
) async throws {}
}
Another example:
actor S {
init(
// Comment this line out and it builds:
isolation: isolated (any Actor)? = #isolation
) {
fatalError()
}
func f() -> S {
fatalError()
}
}
func f() async {
_ = await S().f()
}
Description
This is a more concise reproducible than others I've seen. Calling an isolated method on an actor from a MainActor-isolated class fails to build if done in the same call with a function result, but succeeds if I break it down to 2 separate calls. cc @gottesmm
FWIW this built in Xcode 16 b2, fails in Xcode 16 b3 and b4. Also builds with latest release/6.0 toolchain 600202407211a, not sure if that means already fixed but not yet shipped in Xcode.
Reproduction
Expected behavior
Builds successfully.
Environment
Additional information
No response