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-2153] Deprecation warning despite #available check #44761

Closed
jadengeller mannequin opened this issue Jul 22, 2016 · 4 comments
Closed

[SR-2153] Deprecation warning despite #available check #44761

jadengeller mannequin opened this issue Jul 22, 2016 · 4 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. SDKOverlay standard library Area: Standard library umbrella

Comments

@jadengeller
Copy link
Mannequin

jadengeller mannequin commented Jul 22, 2016

Previous ID SR-2153
Radar None
Original Reporter @JadenGeller
Type Bug

Attachment: Download

Environment

Xcode 8

Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug, SDKOverlay
Assignee @devincoughlin
Priority Medium

md5: 886c724a1a911dff6105c7227062f318

cloned to:

Issue Description:

The following code shows a deprecation warning on `priorityBackground` when the deployment target is set to OS X 10.9.

import Foundation

let attributes: DispatchQueue.GlobalAttributes
if #available(OSX 10.10, *) {
    attributes = DispatchQueue.GlobalAttributes.qosBackground
} else {
    attributes = DispatchQueue.GlobalAttributes.priorityBackground
}
@devincoughlin
Copy link
Member

It looks like some of the Dispatch overlay availability attributes are wonky:
{{
@available(OSX, deprecated: 10.10, message: "Use qos attributes instead")
@available(*, deprecated: 8.0, message: "Use qos attributes instead")
public static let priorityBackground: DispatchQueue.GlobalAttributes
}}

This says priorityBackground is deprecated on all OSes on version 8.0. (This means the compiler thinks was it deprecated on macOS 8.0, which was released in 1997.) Since the minimum deployment target of the attached project is 10.9 and 8.0 < 10.9 the compiler warns that the API is deprecated on all potential deployment target versions.

There are a couple of issues going on here:

(1) We should never allow the wildcard platform in an @available with a specific version. It never makes sense to say "this declaration was deprecated on all platforms in version 4.0)" and so Sema should treat it as an error.
(2) The current interpretation of * in @available is counter-intuitive and differs from its interpretation in #available. In my opinion, the natural interpretation of:
{{
@available(OSX, deprecated=10.10)
@available(*, deprecated)
func foo() { }
}}
is "foo() was deprecated on OSX in version 10.10 and is deprecated for all versions on all other platforms."

Unfortunately, the current interpretation is "foo() is deprecated on all versions of all platforms" – that is, the * wins. This is in contrast to the interpretation of #available where '*' means "all other platforms not explicitly listed"

(3) Regardless of (1) and (2) we need to fix the false positive warnings that users are being now. With the existing compiler, the best way to do this is to update the @available deprecations to explicitly mention watchOS and tvOS:
{{
@available(OSX, deprecated: 10.10, message: "Use qos attributes instead")
@available(iOS, deprecated: 8.0, message: "Use qos attributes instead")
@available(watchOS, deprecated, message: "Use qos attributes instead")
@available(tvOS, deprecated, message: "Use qos attributes instead")
public static let priorityBackground: DispatchQueue.GlobalAttributes
}}

Let's use this SR to track (3), but I think (2) is quite important. I'll file a separate SR for it.

@devincoughlin
Copy link
Member

These APIs were renamed in 8ac413a0b5a9f927f44438df3376a7757f607953. They are still misannotated, though.

@devincoughlin
Copy link
Member

There is a fix for the mis-annotations in #3797

@Dante-Broggi
Copy link
Contributor

Should this be closed as the mis-annotation fix PR is merged?

@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
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. SDKOverlay standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

3 participants