mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[cxx-interop] Allow AppKit & UIKit to be rebuilt with C++ interop enabled
This removes a workaround from the module interface loader, which was forcing AppKit and UIKit to be rebuilt from their textual interfaces with C++ interop disabled, even if the current compilation explicitly enables it.
The workaround was previously put in place because of a compiler error:
```
error: type 'AttributeScopes.AppKitAttributes.StrikethroughStyleAttribute' does not conform to protocol 'AttributedStringKey'
note: possibly intended match 'AttributeScopes.AppKitAttributes.StrikethroughStyleAttribute.Value' (aka 'NSUnderlineStyle') does not conform to 'Hashable'
```
`NSUnderlineStyle` is a C/C++ type from AppKit that is declared using `NS_OPTIONS` macro. `NS_OPTIONS`/`CF_OPTIONS` macros have different expansions in C vs C++ language modes. The C++ expansions weren't handled correctly by ClangImporter, resulting in two distinct Swift types being created: a `typealias NSUnderlineStyle` which was marked as unavailable in Swift, and `enum NSUnderlineStyle`. This mostly worked fine, since the lookup logic was picking the enum during regular name lookup. However, this silently broke down when rebuilding the explicit conformance from `AppKit.swiftinterface`:
```
extension AppKit.NSUnderlineStyle : Swift.Hashable {}
```
Swift was picking the (unavailable) typealias when rebuilding this extension, which means the (available) enum wasn't getting the conformance.
This is verified by an existing test (`test/Interop/Cxx/objc-correctness/appkit-uikit.swift`).
rdar://142961112
This commit is contained in:
@@ -2106,10 +2106,7 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
|
||||
// interop enabled by the Swift CI because it uses an old host SDK.
|
||||
// FIXME: Hack for CoreGraphics.swiftmodule, which cannot be rebuilt because
|
||||
// of a CF_OPTIONS bug (rdar://142762174).
|
||||
// FIXME: Hack for AppKit.swiftmodule / UIKit.swiftmodule, which cannot be
|
||||
// rebuilt because of an NS_OPTIONS bug (rdar://143033209)
|
||||
if (moduleName == "Darwin" || moduleName == "CoreGraphics"
|
||||
|| moduleName == "AppKit" || moduleName == "UIKit") {
|
||||
if (moduleName == "Darwin" || moduleName == "CoreGraphics") {
|
||||
subInvocation.getLangOptions().EnableCXXInterop = false;
|
||||
subInvocation.getLangOptions().cxxInteropCompatVersion = {};
|
||||
BuildArgs.erase(llvm::remove_if(BuildArgs,
|
||||
|
||||
Reference in New Issue
Block a user