[SR-15051] Swift should suggest updating existing @available attribute when you use an insufficiently available declaration #57378
Labels
availability
The @available attribute and availability checking in general
compiler
The Swift compiler itself
diagnostics QoI
Bug: Diagnostics Quality of Implementation
fix-its
Feature: diagnostic fix-its
good first issue
Good for newcomers
improvement
type checker
Area → compiler: Semantic analysis
Additional Detail from JIRA
md5: 9db411fbe711e822a955f04325204e6d
Issue Description:
Currently,
fixAvailabilityForDecl()
in TypeCheckAvailability.cpp exits early if there is already an@available
attribute on the declaration, with a comment noting work that should be done in the future:Indeed, we should make this change. For instance, if you give the compiler this code:
Swift should emit a note with a fix-it replacing "macOS 12" with "macOS 42".
Your implementation, should you choose to commit it, should test not only this easy case with one simple
@available
attribute, but also cases with multiple OSes and long-form@available
attributes. You will certainly need to update some existing tests; those might adequately cover this, but I'm not sure.The text was updated successfully, but these errors were encountered: