You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AST: Track platform unavailability and introduction as separate constraints.
Potential unavailability of a declaration is always diagnosed in a context that
does not have a sufficient platform introduction constraint, even if that
context is also unavailable on that platform. This behavior is overly strict,
since the potential unavailability will never matter, but it's a longstanding
quirk of availability checking. As a result, some source code has been written
to work around this quirk by marking declarations as simultaneously unavailable
and introduced for a given platform:
```
@available(macOS, unavailable, introduced: 15)
func unavailableAndIntroducedInMacOS15() {
// ... allowed to call functions introduced in macOS 15.
}
```
When availability checking was refactored to be based on a constraint engine in
#79260, the compiler started effectively
treating `@available(macOS, unavailable, introduced: 15)` as just
`@available(macOS, unavailable)` because the introduction constraint was
treated as lower priority and therefore superseded by the unavailability
constraint. This caused a regression for the code that was written to work
around the availability checker's strictness.
The fix is to allow the constraint engine to track multiple kinds of
constraints per-domain which in turn ensures that the platform introduction of
an availability context can be further refined even if that context is also
unavailable.
A better fix would be to stop diagnosing potential unavailability entirely in
unavailable contexts but that change is out of scope for the 6.2 release.
Resolves rdar://147945883.
e.never_available_extension_osx_future_method() // expected-error {{'never_available_extension_osx_future_method()' is unavailable}}
388
-
e.osx_extension_osx_future_method()
388
+
e.osx_extension_osx_future_method() // expected-error {{'osx_extension_osx_future_method()' is only available in macOS 99 or newer}}
389
+
// expected-note@-1 {{add 'if #available' version check}}
389
390
e.osx_app_extension_extension_osx_future_method() // expected-error {{'osx_app_extension_extension_osx_future_method()' is only available in macOS 99 or newer}}
390
391
// expected-note@-1 {{add 'if #available' version check}}
391
392
e.osx_app_extension_extension_never_available_method() // expected-error {{'osx_app_extension_extension_never_available_method()' is unavailable}}
0 commit comments