When diagnosing a declaration that is more available than its context, to
preserve source compatibility we need to downgrade the diagnostic to a warning
when the outermost declaration is an extension. This logic regressed with
https://github.com/swiftlang/swift/pull/77950 and my earlier attempt to fix
this (https://github.com/swiftlang/swift/pull/78832) misidentified what had
regressed.
Really resolves rdar://143423070.
Downgrade the `cannot be more available than enclosing scope` error to a
warning when the attribute making the decl too available is specified for a
less specific platform.
Resolves rdar://143423070.
As much as possible, we should avoid using `REQUIRES: maccatalyst_support`
since tests restricted this way are not run in PR tests. Many tests that
exercise macCatalyst behaviors can be run in a macOS configuration, without
full macCatalyst standard library support.
Also, adopt `%target-cpu` lit substitution where appropriate to avoid needless
standard library module rebuilds when running tests locally.
This has the effect of rejecting unavailable overrides to available
methods in a similar way as overrides that are less available than the
introduction are rejected.
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.
Add a platform kind and availability attributes for macCatalyst. macCatalyst
uses iOS version numbers and inherits availability from iOS attributes unless
a macCatalyst attribute is explicitly provided.