From 55bd7ad81ad5965de6177f20f2ce0c339d1432a4 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 28 Oct 2025 19:48:42 -0700 Subject: [PATCH 1/7] Add type alias for _GUID --- stdlib/public/Windows/WinSDK.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stdlib/public/Windows/WinSDK.swift b/stdlib/public/Windows/WinSDK.swift index 435adbad3c51d..68efad102e54b 100644 --- a/stdlib/public/Windows/WinSDK.swift +++ b/stdlib/public/Windows/WinSDK.swift @@ -14,6 +14,8 @@ @_exported import _GUIDDef @_exported import WinSDK // Clang module +public typealias _GUID = GUID + // WinBase.h @inlinable public var HANDLE_FLAG_INHERIT: DWORD { From 5a9cc6600afc467e39d2a4c3df331e6fa5523fde Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 29 Oct 2025 09:55:39 -0700 Subject: [PATCH 2/7] Conditionally define the equality overload on cxx import --- stdlib/public/Windows/WinSDK.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stdlib/public/Windows/WinSDK.swift b/stdlib/public/Windows/WinSDK.swift index 68efad102e54b..5eede976b7070 100644 --- a/stdlib/public/Windows/WinSDK.swift +++ b/stdlib/public/Windows/WinSDK.swift @@ -336,12 +336,17 @@ extension GUID { // These conformances are marked @retroactive because the GUID type nominally // comes from the _GUIDDef clang module rather than the WinSDK clang module. +// The C++ overlay already vends `==` when interop is enabled; avoid a redeclaration. +#if canImport(Cxx) +extension GUID: @retroactive Equatable {} +#else extension GUID: @retroactive Equatable { @_transparent public static func ==(lhs: Self, rhs: Self) -> Bool { lhs.uint128Value == rhs.uint128Value } } +#endif extension GUID: @retroactive Hashable { @_transparent From 2d5daed5890a0bde657ae517a94ba8ac634f29d7 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 30 Oct 2025 09:47:21 -0700 Subject: [PATCH 3/7] Switft to __equals function --- stdlib/public/Windows/WinSDK.swift | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/stdlib/public/Windows/WinSDK.swift b/stdlib/public/Windows/WinSDK.swift index 5eede976b7070..98b8056cc40d5 100644 --- a/stdlib/public/Windows/WinSDK.swift +++ b/stdlib/public/Windows/WinSDK.swift @@ -335,18 +335,13 @@ extension GUID { // These conformances are marked @retroactive because the GUID type nominally // comes from the _GUIDDef clang module rather than the WinSDK clang module. - -// The C++ overlay already vends `==` when interop is enabled; avoid a redeclaration. -#if canImport(Cxx) -extension GUID: @retroactive Equatable {} -#else extension GUID: @retroactive Equatable { @_transparent - public static func ==(lhs: Self, rhs: Self) -> Bool { + @_implements(Equatable, ==(_:_:)) + public static func __equals(lhs: Self, rhs: Self) -> Bool { lhs.uint128Value == rhs.uint128Value } } -#endif extension GUID: @retroactive Hashable { @_transparent From 516461dbd808b450d7fb37216fd7b9a90e69a496 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy <8000722+mhegazy@users.noreply.github.com> Date: Thu, 30 Oct 2025 10:29:48 -0700 Subject: [PATCH 4/7] Update stdlib/public/Windows/WinSDK.swift Co-authored-by: Jonathan Grynspan --- stdlib/public/Windows/WinSDK.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stdlib/public/Windows/WinSDK.swift b/stdlib/public/Windows/WinSDK.swift index 98b8056cc40d5..42e2525cb50f1 100644 --- a/stdlib/public/Windows/WinSDK.swift +++ b/stdlib/public/Windows/WinSDK.swift @@ -339,6 +339,9 @@ extension GUID: @retroactive Equatable { @_transparent @_implements(Equatable, ==(_:_:)) public static func __equals(lhs: Self, rhs: Self) -> Bool { + // When C++ interop is enabled, Swift imports a == operator from guiddef.h + // that conflicts with the definition of == here, so we've renamed it to + // __equals to avoid the conflict. lhs.uint128Value == rhs.uint128Value } } From 2824afde651bae80174fb399d538d52625864b33 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 3 Nov 2025 14:16:33 -0800 Subject: [PATCH 5/7] Remove type alias --- stdlib/public/Windows/WinSDK.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/stdlib/public/Windows/WinSDK.swift b/stdlib/public/Windows/WinSDK.swift index 42e2525cb50f1..5b7f0f51863d5 100644 --- a/stdlib/public/Windows/WinSDK.swift +++ b/stdlib/public/Windows/WinSDK.swift @@ -14,8 +14,6 @@ @_exported import _GUIDDef @_exported import WinSDK // Clang module -public typealias _GUID = GUID - // WinBase.h @inlinable public var HANDLE_FLAG_INHERIT: DWORD { From d5b04cd31239e1e16e0a2c3bd6063f7c325d57a3 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 3 Nov 2025 14:17:36 -0800 Subject: [PATCH 6/7] Restore white space --- stdlib/public/Windows/WinSDK.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/public/Windows/WinSDK.swift b/stdlib/public/Windows/WinSDK.swift index 5b7f0f51863d5..b453ea11d73f8 100644 --- a/stdlib/public/Windows/WinSDK.swift +++ b/stdlib/public/Windows/WinSDK.swift @@ -333,6 +333,7 @@ extension GUID { // These conformances are marked @retroactive because the GUID type nominally // comes from the _GUIDDef clang module rather than the WinSDK clang module. + extension GUID: @retroactive Equatable { @_transparent @_implements(Equatable, ==(_:_:)) From f6ff4672714de27850d48d35f64602ed94a76904 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 3 Nov 2025 14:18:44 -0800 Subject: [PATCH 7/7] Move comment higher --- stdlib/public/Windows/WinSDK.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/public/Windows/WinSDK.swift b/stdlib/public/Windows/WinSDK.swift index b453ea11d73f8..0d3218844d0d8 100644 --- a/stdlib/public/Windows/WinSDK.swift +++ b/stdlib/public/Windows/WinSDK.swift @@ -335,12 +335,12 @@ extension GUID { // comes from the _GUIDDef clang module rather than the WinSDK clang module. extension GUID: @retroactive Equatable { - @_transparent - @_implements(Equatable, ==(_:_:)) - public static func __equals(lhs: Self, rhs: Self) -> Bool { // When C++ interop is enabled, Swift imports a == operator from guiddef.h // that conflicts with the definition of == here, so we've renamed it to // __equals to avoid the conflict. + @_transparent + @_implements(Equatable, ==(_:_:)) + public static func __equals(lhs: Self, rhs: Self) -> Bool { lhs.uint128Value == rhs.uint128Value } }