Skip to content

Commit f848fe0

Browse files
authored
Merge pull request swiftlang#4978 from parkera/parkera/bundle_sendable_6.0
[Swift 6.0] Mark Bundle as Sendable
2 parents 0a0a4df + 527da83 commit f848fe0

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

Sources/Foundation/Bundle.swift

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
@_silgen_name("swift_getTypeContextDescriptor")
1313
private func _getTypeContextDescriptor(of cls: AnyClass) -> UnsafeRawPointer
1414

15-
open class Bundle: NSObject {
16-
private var _bundleStorage: AnyObject!
17-
private final var _bundle: CFBundle! {
18-
get { unsafeBitCast(_bundleStorage, to: CFBundle?.self) }
19-
set { _bundleStorage = newValue }
15+
open class Bundle: NSObject, @unchecked Sendable {
16+
private let _bundleStorage: AnyObject!
17+
private var _bundle: CFBundle! {
18+
unsafeBitCast(_bundleStorage, to: CFBundle?.self)
2019
}
2120

2221
public static var _supportsFHSBundles: Bool {
@@ -82,13 +81,11 @@ open class Bundle: NSObject {
8281
}
8382

8483
internal init(cfBundle: CFBundle) {
84+
_bundleStorage = cfBundle
8585
super.init()
86-
_bundle = cfBundle
8786
}
8887

8988
public init?(path: String) {
90-
super.init()
91-
9289
// TODO: We do not yet resolve symlinks, but we must for compatibility
9390
// let resolvedPath = path._nsObject.stringByResolvingSymlinksInPath
9491
let resolvedPath = path
@@ -101,6 +98,8 @@ open class Bundle: NSObject {
10198
if (_bundleStorage == nil) {
10299
return nil
103100
}
101+
102+
super.init()
104103
}
105104

106105
public convenience init?(url: URL) {
@@ -134,13 +133,12 @@ open class Bundle: NSObject {
134133
}
135134

136135
public init?(identifier: String) {
137-
super.init()
138-
139136
guard let result = CFBundleGetBundleWithIdentifier(identifier._cfObject) else {
140137
return nil
141138
}
142139

143-
_bundle = result
140+
_bundleStorage = result
141+
super.init()
144142
}
145143

146144
public convenience init?(_executableURL: URL) {

0 commit comments

Comments
 (0)