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-8168] @available(iOS, obsoleted: 10.0) Does Not Prevent Function Execution #50700

Closed
swift-ci opened this issue Jul 2, 2018 · 3 comments
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 2, 2018

Previous ID SR-8168
Radar None
Original Reporter jhoffmann (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 8a0bd131195677f0720f33b822428475

Issue Description:

Placing @avilable(iOS, obsoleted) above a function is not preventing the execution of that function on newer platforms.

Example:

override func viewDidLoad() {
     super.viewDidLoad()        
     testFunc()
}
    
@available(iOS, obsoleted: 10.0)
func testFunc() {
     print("testFunc")
}
@available(iOS, obsoleted: 10.0)
    override func invalidationContext(forPreferredLayoutAttributes preferredAttributes: UICollectionViewLayoutAttributes, withOriginalAttributes originalAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutInvalidationContext
@belkadan
Copy link
Contributor

belkadan commented Jul 2, 2018

Yeah, we don't have availability checking for "max allowed OS" implemented yet.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Feb 9, 2020

Comment by Jwa, Min-Kyung (JIRA)

I wonder when this option will be applied in Swift.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@tshortli
Copy link
Contributor

I believe this is implemented. The following fails to type check for a deployment target > macOS 11 with the Swift 5.6 compiler:

@available(macOS, obsoleted: 11.0)
func test() {} // note: 'test()' was obsoleted in macOS 11.0

test() // error: 'test()' is unavailable in macOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

3 participants