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-11860] @available(swift, obsoleted) APIs should be able to call other obsoleted APIs #54271

Open
lilyball mannequin opened this issue Nov 26, 2019 · 2 comments
Open
Labels
compiler The Swift compiler in itself improvement

Comments

@lilyball
Copy link
Mannequin

lilyball mannequin commented Nov 26, 2019

Previous ID SR-11860
Radar rdar://problem/57494818
Original Reporter @lilyball
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement
Assignee None
Priority Medium

md5: bfed417201945d33aeddb362f1d84669

Issue Description:

Swift has no official way to mark an API as Obj-C–only such that it cannot be called from Swift. An idiom adopted by my team is to mark the API as obsoleted since Swift 1.0, thus preventing it from being called from Swift, but still allowing it to be called from Obj-C. The problem is an API marked obsoleted in this fashion cannot call another API marked obsoleted, which is rather restrictive. Here's an example:

import Foundation
class Foo: NSObject {
    @available(swift, obsoleted: 1.0)
    @objc func apiOnlyForObjC() -> ClassOnlyForObjC {
        return ClassOnlyForObjC()
    }
    @objc(FooResult)
    @available(swift, obsoleted: 1.0)
    class ClassOnlyForObjC: NSObject {}
}

Another example would be when I'm providing several variants of an @objc method with different numbers of parameters to simulate optional parameters, I can't have the simpler versions call the more complex versions because they're all marked as obsoleted.

@lilyball
Copy link
Mannequin Author

lilyball mannequin commented Nov 26, 2019

On a similar note I really wish @available(swift, unavailable) was supported, but it's not.

@typesanitizer
Copy link

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself improvement
Projects
None yet
Development

No branches or pull requests

1 participant