Skip to content

Conversation

@beccadax
Copy link
Contributor

@beccadax beccadax commented Apr 14, 2020

Previously, availability checking computed a declaration’s availability as the intersection of all @available attributes with active platforms. This meant that Swift would not allow you to use an API that was available earlier in a child platform than in its parent until it was also available in the parent platform. That was incorrect.

This PR corrects availability checking to find the most specific @available attribute with an introduced: version and use that instead.

Fixes rdar://60892534, rdar://61813677.

Previously, availability checking computed a declaration’s availability as the intersection of all @available attributes with active platforms. This meant that Swift would not allow you to use an API that was available earlier in a child platform than in its parent until it was also available in the parent platform. That was incorrect.

This PR corrects availability checking to find the most specific @available attribute with an introduced version and use that instead.

Fixes rdar://60892534.
@beccadax
Copy link
Contributor Author

This was reviewed internally to Apple by @devincoughlin. It has also been tested there, since Swift CI's ability to test Mac Catalyst changes is currently limited, so I'll stick to a smoke test here.

@beccadax
Copy link
Contributor Author

@swift-ci please smoke test and merge

The previous commit broke a promise made by the implementation it replaced: if there were two or more @available(introduced:) attributes for the same platform, the greatest version wins. This commit restores that property while still completely overriding the parent platform’s availability with a child platform’s.
@beccadax
Copy link
Contributor Author

@swift-ci please test

@beccadax beccadax requested a review from devincoughlin April 17, 2020 09:32
@beccadax
Copy link
Contributor Author

@devincoughlin Requesting a re-review because I discovered a bug in the original implementation.

@swift-ci

This comment has been minimized.

@swift-ci

This comment has been minimized.

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like the right semantics, thanks!

@beccadax beccadax merged commit 2996e93 into swiftlang:master Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants