[SR-15051] Swift should suggest updating existing @available attribute when you use an insufficiently available declaration
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Lĩnh vực
- compilers, testing-qa
Hướng nghiên cứu
Bắt đầu trong TypeCheckAvailability.cpp tại fixAvailabilityForDecl() và kiểm tra các bài kiểm tra chẩn đoán availability hiện có. Theo dõi lệnh return sớm đối với các khai báo có thuộc tính @available hiện có, sau đó bao phủ các thuộc tính đơn giản, thuộc tính cho nhiều OS và thuộc tính dạng dài. Hoàn thành khi các chẩn đoán đề xuất thay thế phiên bản availability không đủ và các bài kiểm tra liên quan đều đạt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
| Previous ID | SR-15051 |
| Radar | rdar://problem/81802673 |
| Original Reporter | @beccadax |
| Type | Improvement |
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler |
| Labels | Improvement, DiagnosticsQoI, StarterBug |
| Assignee | mininny (JIRA) |
| Priority | Medium |
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:
/// Emit a diagnostic note and Fix-It to add an @available attribute
/// on the given declaration for the given version range.
static void fixAvailabilityForDecl(SourceRange ReferenceRange, const Decl *D,
const VersionRange &RequiredRange,
ASTContext &Context) {
// ...irrelevant code omitted...
if (getActiveAvailableAttribute(D, Context)) {
// For QoI, in future should emit a fixit to update the existing attribute.
return;
}
Indeed, we should make this change. For instance, if you give the compiler this code:
@available(macOS 42, *) func foo() {}
@available(macOS 12, *) func bar() {
foo()
}
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.
- Ngôn ngữ chính
- Swift
- Star
- 70.4k
- Fork
- 10.8k
- Merge trung bình
- 2 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 461
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của swiftlang/swift
-
triage needed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
triage needed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Foundation Windows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
triage needed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
triage needed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Tất cả issue của swiftlang/swift
Issue tương tự
-
type: docs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
googleapis/google-cloud-swift#971 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
bitcoindevkit/bdk-ffi#1125 ·
-
Move wallpaper setting Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
mozilla-mobile/firefox-ios#35743 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
manaflow-ai/cmux#13417 ·
-
triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
ionic-team/capacitor#8616 ·