Skip to content

Mark Bundle as Sendable #4963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions Sources/Foundation/Bundle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
@_silgen_name("swift_getTypeContextDescriptor")
private func _getTypeContextDescriptor(of cls: AnyClass) -> UnsafeRawPointer

open class Bundle: NSObject {
private var _bundleStorage: AnyObject!
private final var _bundle: CFBundle! {
get { unsafeBitCast(_bundleStorage, to: CFBundle?.self) }
set { _bundleStorage = newValue }
open class Bundle: NSObject, @unchecked Sendable {
private let _bundleStorage: AnyObject!
private var _bundle: CFBundle! {
unsafeBitCast(_bundleStorage, to: CFBundle?.self)
}

public static var _supportsFHSBundles: Bool {
Expand Down Expand Up @@ -82,13 +81,11 @@ open class Bundle: NSObject {
}

internal init(cfBundle: CFBundle) {
_bundleStorage = cfBundle
super.init()
_bundle = cfBundle
}

public init?(path: String) {
super.init()

// TODO: We do not yet resolve symlinks, but we must for compatibility
// let resolvedPath = path._nsObject.stringByResolvingSymlinksInPath
let resolvedPath = path
Expand All @@ -101,6 +98,8 @@ open class Bundle: NSObject {
if (_bundleStorage == nil) {
return nil
}

super.init()
}

public convenience init?(url: URL) {
Expand Down Expand Up @@ -134,13 +133,12 @@ open class Bundle: NSObject {
}

public init?(identifier: String) {
super.init()

guard let result = CFBundleGetBundleWithIdentifier(identifier._cfObject) else {
return nil
}

_bundle = result
_bundleStorage = result
super.init()
}

public convenience init?(_executableURL: URL) {
Expand Down