-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[SR-6419] Use @available(*, unavailable)
instead of inappropriate @available(*, obsoleted: 4.0)
#1323
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
Conversation
One of the reasons for having the obsoleted API is that it should allow users (who are not using the escaping closure) to perform a rename of the call. However, for trailing closures whose API is not being called this probably doesn't make sense. I'm not sure if the right fix is to allow the obsoleted calls to be filtered from the swift compiler if it can't find an exact match, or to remove this overload (added in 7eefc15 as part of a different change). @ianpartridge what do you think, since you reviewed the addition of the obsoleted call? |
This is an interesting issue. I didn't consider the case of someone using trailing closure syntax and hence not providing the parameter name. I'm curious how this works on Darwin, surely the same issue would be seen there? It obviously isn't seen there though, so I must be missing something... |
I think we usually don't keep obsoleted APIs in SCLF (e.g. #1315) so
would not be a rationale. |
As is trivial to search in the codebase, this isn't necessarily always the case: https://github.com/apple/swift-corelibs-foundation/search?utf8=✓&q=renamed&type= The hints are here to allow the fix-its to move forward. Though I wonder, @ianpartridge, whether we should have used 'unavailable' rather than 'obsoleted' here? Would that solve the problem? |
@@ -188,11 +188,6 @@ open class NotificationCenter: NSObject { | |||
}) | |||
} | |||
|
|||
@available(*,obsoleted:4.0,renamed:"addObserver(forName:object:queue:using:)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of deleting this, does changing 'obsoleted' to 'unavailable' fix the problem?
We used |
You get the same effect with |
Let’s check if the unavailable option works and doesn’t cause problems with the original issue, and that it allows the fixme transition to work if not using a trailing closure. Only if we find an issue with that approach should we consider deleting it.
|
Or maybe we should explicitly use
|
NotificationCenter.addObserver(forName:object:queue:usingBlock:)
swift
should be used instead of *
for @available
Updated to use |
@alblue @ianpartridge Please re-check this. |
@swift-ci Please test |
cc @parkera |
Please update this to use unavailable as requested, thanks.
|
Hm then I’m not sure why |
…@available(*, obsoleted: 4.0)` `swift` should be used instead of `*` with `obsoleted: 4.0` here. But somehow use `unavailable` (as requested).
swift
should be used instead of *
for @available
@available(*, unavailable)
instead of inappropriate @available(*, obsoleted: 4.0)
@alblue Done |
@swift-ci Please test |
@swift-ci please test |
@swift-ci please test and merge |
Fixes SR-6419.