@@ -151,12 +151,9 @@ class DeclAttribute : public AttributeBase {
151
151
Value : 32
152
152
);
153
153
154
- SWIFT_INLINE_BITFIELD (AvailableAttr, DeclAttribute, 8 +8 +1 +1 +1 +1 ,
155
- // / A `PlatformKind` value.
156
- Platform : 8 ,
157
-
158
- // / A `PlatformAgnosticAvailabilityKind` value.
159
- PlatformAgnostic : 8 ,
154
+ SWIFT_INLINE_BITFIELD (AvailableAttr, DeclAttribute, 4 +1 +1 +1 +1 ,
155
+ // / An `AvailableAttr::Kind` value.
156
+ Kind : 4 ,
160
157
161
158
// / State storage for `RenamedDeclRequest`.
162
159
HasComputedRenamedDecl : 1 ,
@@ -719,38 +716,31 @@ enum class AvailableVersionComparison {
719
716
Obsoleted,
720
717
};
721
718
722
- // / Describes the platform-agnostic availability of a declaration.
723
- enum class PlatformAgnosticAvailabilityKind : uint8_t {
724
- // / The associated availability attribute is not platform-agnostic.
725
- None,
726
- // / The declaration is deprecated, but can still be used.
727
- Deprecated,
728
- // / The declaration is unavailable in Swift, specifically
729
- UnavailableInSwift,
730
- // / The declaration is available in some but not all versions
731
- // / of Swift, as specified by the VersionTuple members.
732
- SwiftVersionSpecific,
733
- // / The declaration is available in some but not all versions
734
- // / of SwiftPM's PackageDescription library, as specified by
735
- // / the VersionTuple members.
736
- PackageDescriptionVersionSpecific,
737
- // / The declaration is unavailable for other reasons.
738
- Unavailable,
739
- // / The declaration is unavailable from asynchronous contexts
740
- NoAsync,
741
- };
742
-
743
719
// / Defines the @available attribute.
744
720
class AvailableAttr : public DeclAttribute {
745
- public:
746
- AvailableAttr (SourceLoc AtLoc, SourceRange Range, PlatformKind Platform,
747
- StringRef Message, StringRef Rename,
748
- const llvm::VersionTuple &Introduced,
721
+ AvailabilityDomain Domain;
722
+
723
+ public:
724
+ enum class Kind : uint8_t {
725
+ // / The attribute does not specify `deprecated`, `unavailable`,
726
+ // / or `noasync`. Instead, it may specify `introduced:`, `deprecated:`, or
727
+ // / `obsoleted:` versions or it may simply have a `rename:` field.
728
+ Default,
729
+ // / The attribute specifies unconditional deprecation.
730
+ Deprecated,
731
+ // / The attribute specifies unconditional unavailability.
732
+ Unavailable,
733
+ // / The attribute specifies unavailability in asynchronous contexts.
734
+ NoAsync,
735
+ };
736
+
737
+ AvailableAttr (SourceLoc AtLoc, SourceRange Range,
738
+ const AvailabilityDomain &Domain, Kind Kind, StringRef Message,
739
+ StringRef Rename, const llvm::VersionTuple &Introduced,
749
740
SourceRange IntroducedRange,
750
741
const llvm::VersionTuple &Deprecated,
751
742
SourceRange DeprecatedRange,
752
743
const llvm::VersionTuple &Obsoleted, SourceRange ObsoletedRange,
753
- PlatformAgnosticAvailabilityKind PlatformAgnostic,
754
744
bool Implicit, bool IsSPI, bool IsForEmbedded = false );
755
745
756
746
// / The optional message.
@@ -802,16 +792,13 @@ class AvailableAttr : public DeclAttribute {
802
792
// / Whether this attribute was spelled `@_unavailableInEmbedded`.
803
793
bool isForEmbedded () const { return Bits.AvailableAttr .IsForEmbedded ; }
804
794
805
- // / Returns the platform that the attribute applies to (may be `none`).
806
- PlatformKind getPlatform () const {
807
- return static_cast <PlatformKind>(Bits. AvailableAttr . Platform );
808
- }
795
+ // / Returns the `AvailabilityDomain` associated with the attribute, or
796
+ // / `std::nullopt` if it has either not yet been resolved or could not be
797
+ // / resolved successfully.
798
+ std::optional<AvailabilityDomain> getCachedDomain () const { return Domain; }
809
799
810
- // / Returns the platform-agnostic availability.
811
- PlatformAgnosticAvailabilityKind getPlatformAgnosticAvailability () const {
812
- return static_cast <PlatformAgnosticAvailabilityKind>(
813
- Bits.AvailableAttr .PlatformAgnostic );
814
- }
800
+ // / Returns the kind of availability the attribute specifies.
801
+ Kind getKind () const { return static_cast <Kind>(Bits.AvailableAttr .Kind ); }
815
802
816
803
// / Create an `AvailableAttr` that specifies universal unavailability, e.g.
817
804
// / `@available(*, unavailable)`.
0 commit comments