-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Sema: Correctly treat overloads in unavailable extensions as unavailable #77258
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
Sema: Correctly treat overloads in unavailable extensions as unavailable #77258
Conversation
@swift-ci please smoke test |
Looks like I will need to resolve an ambiguity error that arises in Embedded Swift first. Because |
Functions like `fatalError()` have overloads for Embedded Swift only that take StaticString instead of String, since String is unavailable. Unfortunately, many of these overloads create the opportunity for ambiguity in certain contexts. The easiest way to avoid the ambiguities is to mark each of the overloads taking `String` as `@_disfavoredOverload`. Another approach that could work would be to remove the default arguments from the `String` variants in Embedded Swift only, but that would create even more duplication of source code so it doesn't seem worth it.
007b7e0
to
91d73b2
Compare
91d73b2
to
1bededa
Compare
…ble. Instead of checking for unavailability attributes directly in the solver, which does not correctly handle members of unavailable extensions, query `checkDeclarationAvailability()` instead. By using the same underlying logic as the availability checker the constraint solver can be confident in the accuracy of this result. Resolves rdar://87403752.
1bededa
to
98b34c6
Compare
@swift-ci please test |
@swift-ci please test source compatibility |
Instead of checking for unavailability attributes directly in the solver, which does not correctly handle members of unavailable extensions, query
checkDeclarationAvailability()
instead. By using the same underlying logic as the availability checker the constraint solver can be confident in the accuracy of this result.Now that availability of overloads is being checked consistently, an ambiguity in Embedded Swift has been revealed. Functions like
fatalError()
have overloads for Embedded Swift only that takeStaticString
instead ofString
, sinceString
is unavailable. Unfortunately, many of these overloads create the opportunity for ambiguity in certain unavailable contexts. The easiest way to avoid the ambiguities is to mark each of the overloads takingString
as@_disfavoredOverload
. Another approach that could work would be to remove the default arguments from theString
variants in Embedded Swift only, but that would create even more duplication of source code so it doesn't seem worth it.Resolves rdar://87403752.