mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
AST: Introduce a Swift runtime availability domain.
Add support for the `Swift` availability domain, which represents availability with respect to the Swift runtime. Use of this domain is restricted by the experimental feature `SwiftRuntimeAvailability`.
This commit is contained in:
@@ -51,6 +51,9 @@ public:
|
||||
/// Represents availability with respect to Swift language mode.
|
||||
SwiftLanguageMode,
|
||||
|
||||
/// Represents availability with respect to the Swift runtime.
|
||||
SwiftRuntime,
|
||||
|
||||
/// Represents PackageDescription availability.
|
||||
PackageDescription,
|
||||
|
||||
@@ -144,6 +147,10 @@ public:
|
||||
return AvailabilityDomain(Kind::SwiftLanguageMode);
|
||||
}
|
||||
|
||||
static AvailabilityDomain forSwiftRuntime() {
|
||||
return AvailabilityDomain(Kind::SwiftRuntime);
|
||||
}
|
||||
|
||||
static AvailabilityDomain forPackageDescription() {
|
||||
return AvailabilityDomain(Kind::PackageDescription);
|
||||
}
|
||||
@@ -185,6 +192,8 @@ public:
|
||||
return getKind() == Kind::SwiftLanguageMode;
|
||||
}
|
||||
|
||||
bool isSwiftRuntime() const { return getKind() == Kind::SwiftRuntime; }
|
||||
|
||||
bool isPackageDescription() const {
|
||||
return getKind() == Kind::PackageDescription;
|
||||
}
|
||||
@@ -236,6 +245,10 @@ public:
|
||||
bool isActivePlatform(const ASTContext &ctx,
|
||||
bool forTargetVariant = false) const;
|
||||
|
||||
/// Returns true if availability in this domain must be specified alone in
|
||||
/// `@available` attributes and `if #available` queries.
|
||||
bool mustBeSpecifiedAlone() const;
|
||||
|
||||
/// Returns the domain's minimum available range for type checking. For
|
||||
/// example, for the domain of the platform that compilation is targeting,
|
||||
/// this version is specified with the `-target` option. For the Swift
|
||||
|
||||
@@ -188,6 +188,9 @@ namespace swift {
|
||||
/// Swift runtime version to compile for.
|
||||
version::Version RuntimeVersion = version::Version::getCurrentLanguageVersion();
|
||||
|
||||
/// The minimum Swift runtime version that the progam can be deployed to.
|
||||
version::Version MinSwiftRuntimeVersion;
|
||||
|
||||
/// PackageDescription version to compile for.
|
||||
version::Version PackageDescriptionVersion;
|
||||
|
||||
|
||||
@@ -298,6 +298,13 @@ def language_mode : Separate<["-"], "language-mode">,
|
||||
MetaVarName<"<mode>">,
|
||||
Alias<swift_version>;
|
||||
|
||||
def min_swift_runtime_version
|
||||
: Separate<["-"], "min-swift-runtime-version">,
|
||||
Flags<[FrontendOption, ModuleInterfaceOptionIgnorable]>,
|
||||
HelpText<"The minimum Swift runtime version "
|
||||
"that will be available at runtime">,
|
||||
MetaVarName<"<vers>">;
|
||||
|
||||
def package_description_version: Separate<["-"], "package-description-version">,
|
||||
Flags<[FrontendOption, HelpHidden, ModuleInterfaceOption]>,
|
||||
HelpText<"The version number to be applied on the input for the PackageDescription availability kind">,
|
||||
|
||||
Reference in New Issue
Block a user