mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Address GUID type definition errors (#85196)
In https://github.com/swiftlang/swift/pull/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 <grynspan@me.com>
This commit is contained in:
@@ -335,8 +335,12 @@ extension GUID {
|
||||
// comes from the _GUIDDef clang module rather than the WinSDK clang module.
|
||||
|
||||
extension GUID: @retroactive Equatable {
|
||||
// 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
|
||||
public static func ==(lhs: Self, rhs: Self) -> Bool {
|
||||
@_implements(Equatable, ==(_:_:))
|
||||
public static func __equals(lhs: Self, rhs: Self) -> Bool {
|
||||
lhs.uint128Value == rhs.uint128Value
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user