Skip to content
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

[SR-740] dispatch_semaphore_t is not convertible to AnyObject #753

Closed
drewcrawford opened this issue Feb 15, 2016 · 4 comments
Closed

[SR-740] dispatch_semaphore_t is not convertible to AnyObject #753

drewcrawford opened this issue Feb 15, 2016 · 4 comments

Comments

@drewcrawford
Copy link
Contributor

Previous ID SR-740
Radar None
Original Reporter @drewcrawford
Type Bug
Status Resolved
Resolution Won't Do
Environment

Linux x64
swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a

Additional Detail from JIRA
Votes 0
Component/s libdispatch
Labels Bug, Linux
Assignee dgrove-oss (JIRA)
Priority Medium

md5: 12999cfe1773782d3e3be803c7f86303

Issue Description:

in Darwin, the following program is legal:

import Dispatch
let a: AnyObject = dispatch_semaphore_create(0)

On Linux, it produces the error:

error: value of type 'dispatch_semaphore_t' (aka 'COpaquePointer') does not conform to specified type 'AnyObject'
@belkadan
Copy link

Hm, this could be a problem: on Linux they aren't objects.

@drewcrawford
Copy link
Contributor Author

For background, the code motivating this bug is an Array extension:

extension RangeReplaceableCollectionType where Generator.Element : AnyObject {
    /// Remove first colleciton element that matches the given reference
    mutating func removeItemMatchingReference(object : Generator.Element) {
        if let index = self.indexOf({$0 === object}) {
            self.removeAtIndex(index)
        }
    }
}

This code can be used to remove a semaphore from an array.

It is actually quite nonintuitive to fix this code to compile on Linux (although I did), chiefly because there is nothing obvious one can replace the where Generator.Element : AnyObject with that works for dispatch_sempahore_t.

Are we not going to bridge the dispatch objects to AnyObject (e.g. not necessarily NSObject) on the Swift runtime? I know NSObject bridging isn't available, but I think AnyObject would be appropriate to bridge...

@swift-ci
Copy link

Comment by David Grove (JIRA)

I submitted #61 which fixes this issue.

@swift-ci
Copy link

Comment by David Grove (JIRA)

made obsolete by Swift 3 dispatch overlay changes.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants