mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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
40 lines
1.7 KiB
Swift
40 lines
1.7 KiB
Swift
// RUN: %target-swift-ide-test -print-module -module-to-print=CenumsNSOptions -I %S/Inputs -source-filename=x -enable-experimental-cxx-interop | %FileCheck %s
|
|
// REQUIRES: objc_interop
|
|
|
|
import CenumsNSOptions
|
|
|
|
// CHECK-NOT: typealias NSBinarySearchingOptions = UInt
|
|
|
|
// CHECK: struct NSBinarySearchingOptions : OptionSet, @unchecked Sendable {
|
|
// CHECK-NEXT: init(rawValue: UInt)
|
|
// CHECK-NEXT: let rawValue: UInt
|
|
// CHECK-NEXT: typealias RawValue = UInt
|
|
// CHECK-NEXT: typealias Element = NSBinarySearchingOptions
|
|
// CHECK-NEXT: typealias ArrayLiteralElement = NSBinarySearchingOptions
|
|
// CHECK-NEXT: static var firstEqual: NSBinarySearchingOptions { get }
|
|
// CHECK-NEXT: @available(swift, obsoleted: 3, renamed: "firstEqual")
|
|
// CHECK-NEXT: static var FirstEqual: NSBinarySearchingOptions { get }
|
|
// CHECK-NEXT: static var lastEqual: NSBinarySearchingOptions { get }
|
|
// CHECK-NEXT: @available(swift, obsoleted: 3, renamed: "lastEqual")
|
|
// CHECK-NEXT: static var LastEqual: NSBinarySearchingOptions { get }
|
|
// CHECK-NEXT: static var insertionIndex: NSBinarySearchingOptions { get }
|
|
// CHECK-NEXT: @available(swift, obsoleted: 3, renamed: "insertionIndex")
|
|
// CHECK-NEXT: static var InsertionIndex: NSBinarySearchingOptions { get }
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK: struct Bar : OptionSet, @unchecked Sendable
|
|
// CHECK: struct HasNSOptionField {
|
|
// CHECK: var bar: Bar
|
|
// CHECK: }
|
|
|
|
// CHECK: class HasNSOptionFieldObjC {
|
|
// CHECK-NEXT: var bar: Bar
|
|
// CHECK-NEXT: class func bar() -> Bar
|
|
// CHECK-NEXT: class func setBar(_ bar: Bar)
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK: class HasNSOptionFieldObjC2 {
|
|
// CHECK-NEXT: class func setBar(_ bar: Bar)
|
|
// CHECK-NEXT: func setBar(_ bar: Bar)
|
|
// CHECK-NEXT: }
|