Skip to content

Commit d3e7af1

Browse files
committed
Tests: repair the build on Windows
The adoption of Swift 6 triggered a failure on Windows. `HANDLE` is a typealias for a pointer. This value is sendable. As this is a typealias to `UnsafePointer<VOID__>` we require that the sendable conformance is in the `Swift` module. However, that is not possible. Provide a retroactive conformance to make the capture concurrency safe.
1 parent ce1349c commit d3e7af1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Tests/SwiftBuildTests/ConsoleCommands/ServiceConsoleTests.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,19 @@ fileprivate struct ServiceConsoleTests {
116116
}
117117
}
118118

119+
#if os(Windows)
120+
private var SYNCHRONIZE: DWORD {
121+
DWORD(WinSDK.SYNCHRONIZE)
122+
}
123+
124+
extension HANDLE: @retroactive @unchecked Sendable {}
125+
#endif
126+
119127
extension Processes {
120128
fileprivate static func exitPromise(pid: pid_t) throws -> Promise<Void, any Error> {
121129
let promise = Promise<Void, any Error>()
122130
#if os(Windows)
123-
guard let proc = OpenProcess(DWORD(SYNCHRONIZE), false, DWORD(pid)) else {
131+
guard let proc: HANDLE = OpenProcess(SYNCHRONIZE, false, DWORD(pid)) else {
124132
throw StubError.error("OpenProcess failed with error \(GetLastError())")
125133
}
126134
defer { CloseHandle(proc) }

0 commit comments

Comments
 (0)