Skip to content

Update getSwift56Availability() and add getSwift57Availability() with platform versions #41428

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
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
4 changes: 4 additions & 0 deletions include/swift/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,10 @@ class ASTContext final {
/// compiler for the target platform.
AvailabilityContext getSwift56Availability();

/// Get the runtime availability of features introduced in the Swift 5.7
/// compiler for the target platform.
AvailabilityContext getSwift57Availability();

// Note: Update this function if you add a new getSwiftXYAvailability above.
/// Get the runtime availability for a particular version of Swift (5.0+).
AvailabilityContext
Expand Down
18 changes: 18 additions & 0 deletions lib/AST/Availability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,23 @@ AvailabilityContext ASTContext::getSwift55Availability() {
}

AvailabilityContext ASTContext::getSwift56Availability() {
auto target = LangOpts.Target;

if (target.isMacOSX() ) {
return AvailabilityContext(
VersionRange::allGTE(llvm::VersionTuple(12, 3, 0)));
} else if (target.isiOS()) {
return AvailabilityContext(
VersionRange::allGTE(llvm::VersionTuple(15, 4, 0)));
} else if (target.isWatchOS()) {
return AvailabilityContext(
VersionRange::allGTE(llvm::VersionTuple(8, 5, 0)));
} else {
return AvailabilityContext::alwaysAvailable();
}
}

AvailabilityContext ASTContext::getSwift57Availability() {
return getSwiftFutureAvailability();
}

Expand Down Expand Up @@ -503,6 +520,7 @@ ASTContext::getSwift5PlusAvailability(llvm::VersionTuple swiftVersion) {
case 4: return getSwift54Availability();
case 5: return getSwift55Availability();
case 6: return getSwift56Availability();
case 7: return getSwift57Availability();
default: break;
}
}
Expand Down