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
110 lines
4.7 KiB
Swift
110 lines
4.7 KiB
Swift
// RUN: %target-swift-ide-test -print-module -module-to-print=AnonymousWithSwiftName -I %S/Inputs -source-filename=x -enable-experimental-cxx-interop | %FileCheck %s
|
|
|
|
// CHECK: @available(*, unavailable, message: "Not available in Swift")
|
|
// CHECK: typealias SOColorMask = UInt32
|
|
|
|
// CHECK: struct SOColorMask : OptionSet, @unchecked Sendable {
|
|
// CHECK: init(rawValue: UInt32)
|
|
// CHECK: let rawValue: UInt32
|
|
// CHECK: typealias RawValue = UInt32
|
|
// CHECK: typealias Element = SOColorMask
|
|
// CHECK: typealias ArrayLiteralElement = SOColorMask
|
|
|
|
// CHECK: static var red: SOColorMask { get }
|
|
// CHECK: @available(swift, obsoleted: 3, renamed: "red")
|
|
// CHECK: static var Red: SOColorMask { get }
|
|
|
|
// CHECK: static var green: SOColorMask { get }
|
|
// CHECK: @available(swift, obsoleted: 3, renamed: "green")
|
|
// CHECK: static var Green: SOColorMask { get }
|
|
|
|
// CHECK: static var blue: SOColorMask { get }
|
|
// CHECK: @available(swift, obsoleted: 3, renamed: "blue")
|
|
// CHECK: static var Blue: SOColorMask { get }
|
|
|
|
// CHECK: static var all: SOColorMask { get }
|
|
// CHECK: @available(swift, obsoleted: 3, renamed: "all")
|
|
// CHECK: static var All: SOColorMask { get }
|
|
// CHECK: }
|
|
|
|
// CHECK-NOT: typealias CFColorMask = UInt32
|
|
|
|
// CHECK: struct CFColorMask : OptionSet {
|
|
// CHECK: init(rawValue: UInt32)
|
|
// CHECK: let rawValue: UInt32
|
|
// CHECK: typealias RawValue = UInt32
|
|
// CHECK: typealias Element = CFColorMask
|
|
// CHECK: typealias ArrayLiteralElement = CFColorMask
|
|
|
|
// CHECK: static var red: CFColorMask { get }
|
|
// CHECK: @available(swift, obsoleted: 3, renamed: "red")
|
|
// CHECK: static var Red: CFColorMask { get }
|
|
|
|
// CHECK: static var green: CFColorMask { get }
|
|
// CHECK: @available(swift, obsoleted: 3, renamed: "green")
|
|
// CHECK: static var Green: CFColorMask { get }
|
|
|
|
// CHECK: static var blue: CFColorMask { get }
|
|
// CHECK: @available(swift, obsoleted: 3, renamed: "blue")
|
|
// CHECK: static var Blue: CFColorMask { get }
|
|
|
|
// CHECK: static var all: CFColorMask { get }
|
|
// CHECK: @available(swift, obsoleted: 3, renamed: "all")
|
|
// CHECK: static var All: CFColorMask { get }
|
|
// CHECK: }
|
|
|
|
// CHECK: func useSOColorMask(_ mask: SOColorMask) -> SOColorMask
|
|
// CHECK: func useCFColorMask(_ mask: CFColorMask) -> CFColorMask
|
|
|
|
// Test rename with "swift_name" attr:
|
|
// CHECK: struct ParentStruct
|
|
|
|
// CHECK: @available(swift, obsoleted: 3, renamed: "ParentStruct.childFn(self:)")
|
|
// CHECK: func renameCFColorMask(_ parent: ParentStruct) -> CFColorMask
|
|
|
|
// CHECK: extension ParentStruct {
|
|
// CHECK: func childFn() -> CFColorMask
|
|
// CHECK: @available(*, unavailable, message: "Not available in Swift")
|
|
// CHECK: typealias NewName = UInt32
|
|
// CHECK: struct NewName : OptionSet, @unchecked Sendable {
|
|
// CHECK: init(rawValue: UInt32)
|
|
// CHECK: let rawValue: UInt32
|
|
// CHECK: typealias RawValue = UInt32
|
|
// CHECK: typealias Element = ParentStruct.NewName
|
|
// CHECK: typealias ArrayLiteralElement = ParentStruct.NewName
|
|
// CHECK: static var one: ParentStruct.NewName { get }
|
|
// CHECK: @available(swift, obsoleted: 3, renamed: "one")
|
|
// CHECK: static var One: ParentStruct.NewName { get }
|
|
// CHECK: static var two: ParentStruct.NewName { get }
|
|
// CHECK: @available(swift, obsoleted: 3, renamed: "two")
|
|
// CHECK: static var Two: ParentStruct.NewName { get }
|
|
// CHECK: }
|
|
// CHECK: }
|
|
|
|
// CHECK: @available(swift, obsoleted: 3, renamed: "ParentStruct.NewName")
|
|
// CHECK: @available(*, unavailable, message: "Not available in Swift")
|
|
// CHECK: typealias OldName = ParentStruct.NewName
|
|
|
|
// CHECK: @available(swift, obsoleted: 3, renamed: "ParentStruct.NewName")
|
|
// CHECK: typealias OldName = ParentStruct.NewName
|
|
// CHECK: @available(*, unavailable, message: "Not available in Swift")
|
|
// CHECK: typealias GlobalNewName = UInt32
|
|
// CHECK: @available(swift, obsoleted: 3, renamed: "GlobalNewName")
|
|
// CHECK: @available(*, unavailable, message: "Not available in Swift")
|
|
// CHECK: typealias GlobalOldName = GlobalNewName
|
|
// CHECK: struct GlobalNewName : OptionSet, @unchecked Sendable {
|
|
// CHECK: init(rawValue: UInt32)
|
|
// CHECK: let rawValue: UInt32
|
|
// CHECK: typealias RawValue = UInt32
|
|
// CHECK: typealias Element = GlobalNewName
|
|
// CHECK: typealias ArrayLiteralElement = GlobalNewName
|
|
// CHECK: static var one: GlobalNewName { get }
|
|
// CHECK: @available(swift, obsoleted: 3, renamed: "one")
|
|
// CHECK: static var One: GlobalNewName { get }
|
|
// CHECK: static var two: GlobalNewName { get }
|
|
// CHECK: @available(swift, obsoleted: 3, renamed: "two")
|
|
// CHECK: static var Two: GlobalNewName { get }
|
|
// CHECK: }
|
|
// CHECK: @available(swift, obsoleted: 3, renamed: "GlobalNewName")
|
|
// CHECK: typealias GlobalOldName = GlobalNewName
|