Skip to content

Commit 71882c6

Browse files
committed
[API Notes] Use API notes rather than overlays to make error enums bridge.
The Clang attribute allows one to state that a particular enumeration type describes an error, and associates it with a particular domain constant. However, due to lack of API notes support, this attribute wasn't actually getting used. Instead, we had a number of explicit extensions to enum types to make them conform to the _BridgedNSError protocol explicitly. Now that we have API notes, use them to make these enums into error enums with the appropriate domain, so that the Clang importer will synthesize the _BridgedNSError conformances. Then, remove all of the explicit conformances---and with them, the overlays for 12 frameworks. There is a small fix to more eagerly consider these conformances as "used" if an expression is formed with the error enum as a value type. This better ensures that the conformances will be available at runtime when needed. This cleanup is needed to implement SE-0112 (NSError bridging), although it is useful by itself.
1 parent 1946f95 commit 71882c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+96
-240
lines changed

apinotes/AVFoundation.apinotes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,6 @@ Functions:
243243
Enumerators:
244244
- Name: AVMovieWritingAddMovieHeaderToDestination
245245
SwiftName: addMovieHeaderToDestination
246+
Tags:
247+
- Name: AVError
248+
NSErrorDomain: AVFoundationErrorDomain

apinotes/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@ set(SWIFT_API_NOTES_INPUTS
33
AppKit
44
AudioToolbox
55
CloudKit
6+
CoreBluetooth
67
CoreData
78
CoreGraphics
89
CoreLocation
910
CoreText
1011
Dispatch
12+
EventKit
1113
Foundation
1214
GameKit
1315
HomeKit
16+
Intents
17+
LocalAuthentication
1418
MediaPlayer
19+
MultipeerConnectivity
1520
NotificationCenter
1621
ObjectiveC
1722
PassKit
@@ -22,6 +27,7 @@ set(SWIFT_API_NOTES_INPUTS
2227
TVMLKit
2328
TVServices
2429
UIKit
30+
WatchConnectivity
2531
WatchKit
2632
WebKit
2733
XCTest

apinotes/CloudKit.apinotes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,6 @@ Classes:
4444
- Selector: 'setParentReferenceFromRecordID:'
4545
MethodKind: Instance
4646
SwiftName: 'setParent(_:)'
47+
Tags:
48+
- Name: CKErrorCode
49+
NSErrorDomain: CKErrorDomain

apinotes/Contacts.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
Name: Contacts
3+
Tags:
4+
- Name: CNErrorCode
5+
NSErrorDomain: CNErrorDomain

apinotes/CoreBluetooth.apinotes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
Name: CoreBluetooth
3+
Tags:
4+
- Name: CBError
5+
NSErrorDomain: CBErrorDomain
6+
- Name: CBATTError
7+
NSErrorDomain: CBATTErrorDomain

apinotes/CoreLocation.apinotes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ Protocols:
2020
- Selector: 'locationManager:didChangeAuthorizationStatus:'
2121
SwiftName: 'locationManager(_:didChangeAuthorization:)'
2222
MethodKind: Instance
23+
Tags:
24+
- Name: CLError
25+
NSErrorDomain: kCLErrorDomain

apinotes/EventKit.apinotes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
Name: EventKit
3+
Tags:
4+
- Name: EKErrorCode
5+
NSErrorDomain: EKErrorDomain

apinotes/GameKit.apinotes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
---
12
Name: GameKit
23
Classes:
34
- Name: GKLocalPlayer
45
Methods:
56
- Selector: 'localPlayer'
67
MethodKind: Class
78
FactoryAsInit: C
9+
Tags:
10+
- Name: GKErrorCode
11+
NSErrorDomain: GKErrorDomain

apinotes/HomeKit.apinotes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,6 @@ Classes:
6262
- Selector: 'initWithName:fireDate:timeZone:recurrences:'
6363
SwiftName: 'init(name:fireDate:timeZone:recurrences:)'
6464
MethodKind: Instance
65+
Tags:
66+
- Name: HMErrorCode
67+
NSErrorDomain: HMErrorDomain

apinotes/Intents.apinotes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
Name: Intents
3+
Tags:
4+
- Name: INIntentErrorCode
5+
NSErrorDomain: INIntentErrorDomain

0 commit comments

Comments
 (0)