Skip to content

AST: Fill in ASTContext::getSwift59Availability() #67179

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

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/AST/Availability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,20 @@ AvailabilityContext ASTContext::getSwift58Availability() {
}

AvailabilityContext ASTContext::getSwift59Availability() {
// TODO: Update Availability impl when Swift 5.9 is released
return getSwiftFutureAvailability();
auto target = LangOpts.Target;

if (target.isMacOSX()) {
return AvailabilityContext(
VersionRange::allGTE(llvm::VersionTuple(14, 0, 0)));
} else if (target.isiOS()) {
return AvailabilityContext(
VersionRange::allGTE(llvm::VersionTuple(17, 0, 0)));
} else if (target.isWatchOS()) {
return AvailabilityContext(
VersionRange::allGTE(llvm::VersionTuple(10, 0, 0)));
} else {
return AvailabilityContext::alwaysAvailable();
}
}

AvailabilityContext ASTContext::getSwiftFutureAvailability() {
Expand Down
4 changes: 2 additions & 2 deletions test/Generics/variadic_generic_types_availability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

struct G<each T> {}
// expected-note@-1 {{add @available attribute to enclosing generic struct}}
// expected-error@-2 {{parameter packs in generic types are only available in macOS 99.99.0 or newer}}
// expected-error@-2 {{parameter packs in generic types are only available in macOS 14.0.0 or newer}}

// Type aliases are OK
typealias A<each T> = (repeat each T)
typealias A<each T> = (repeat each T)