Skip to content

Commit 86b0b29

Browse files
mhegazygrynspan
andauthored
Address GUID type definition errors (#85196)
In #84792 we have added implementation to `Equatable` and `Hashable` there are two issues with this. 1. Uses of type `GUID` would be emitted in the `swiftinterface` file as `_GUIDDef._GUID` since it is an external type. but the type name in the imported header file is `GUID` and not `_GUID` 2. When compiling using `-cxx-interoperability-mode=default`, there are duplicate definition errors for `==` since the c++ header file defines the same operator. Proposed changes: 1. Add a type alias `typealias _GUID = GUID` to address the naming mismatch in the generated interface file 2. Add conditional definitions of the equatable implementation to avoid duplicate definitions. --------- Co-authored-by: Jonathan Grynspan <[email protected]>
1 parent 7821c2c commit 86b0b29

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

stdlib/public/Windows/WinSDK.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,12 @@ extension GUID {
335335
// comes from the _GUIDDef clang module rather than the WinSDK clang module.
336336

337337
extension GUID: @retroactive Equatable {
338+
// When C++ interop is enabled, Swift imports a == operator from guiddef.h
339+
// that conflicts with the definition of == here, so we've renamed it to
340+
// __equals to avoid the conflict.
338341
@_transparent
339-
public static func ==(lhs: Self, rhs: Self) -> Bool {
342+
@_implements(Equatable, ==(_:_:))
343+
public static func __equals(lhs: Self, rhs: Self) -> Bool {
340344
lhs.uint128Value == rhs.uint128Value
341345
}
342346
}

0 commit comments

Comments
 (0)