@@ -824,9 +824,6 @@ SemanticAvailableAttrRequest::evaluate(swift::Evaluator &evaluator,
824
824
auto attrLoc = attr->getLocation ();
825
825
auto attrName = attr->getAttrName ();
826
826
auto domainLoc = attr->getDomainLoc ();
827
- auto introducedVersion = attr->getRawIntroduced ();
828
- auto deprecatedVersion = attr->getRawDeprecated ();
829
- auto obsoletedVersion = attr->getRawObsoleted ();
830
827
auto mutableAttr = const_cast <AvailableAttr *>(attr);
831
828
auto domain = attr->getCachedDomain ();
832
829
@@ -867,16 +864,18 @@ SemanticAvailableAttrRequest::evaluate(swift::Evaluator &evaluator,
867
864
auto domainName = domain->getNameForAttributePrinting ();
868
865
auto semanticAttr = SemanticAvailableAttr (attr);
869
866
870
- bool hasVersionSpec =
871
- (introducedVersion || deprecatedVersion || obsoletedVersion);
867
+ bool hasIntroduced = attr->getRawIntroduced ().has_value ();
868
+ bool hasDeprecated = attr->getRawDeprecated ().has_value ();
869
+ auto hasObsoleted = attr->getRawObsoleted ().has_value ();
870
+ bool hasVersionSpec = (hasIntroduced || hasDeprecated || hasObsoleted);
872
871
873
872
if (!domain->isVersioned () && hasVersionSpec) {
874
873
SourceRange versionSourceRange;
875
- if (introducedVersion )
874
+ if (hasIntroduced )
876
875
versionSourceRange = semanticAttr.getIntroducedSourceRange ();
877
- else if (deprecatedVersion )
876
+ else if (hasDeprecated )
878
877
versionSourceRange = semanticAttr.getDeprecatedSourceRange ();
879
- else if (obsoletedVersion )
878
+ else if (hasObsoleted )
880
879
versionSourceRange = semanticAttr.getObsoletedSourceRange ();
881
880
882
881
diags
@@ -915,25 +914,15 @@ SemanticAvailableAttrRequest::evaluate(swift::Evaluator &evaluator,
915
914
}
916
915
}
917
916
918
- // Canonicalize platform versions.
919
- // FIXME: [availability] This should be done when remapping versions instead.
920
- if (domain->isPlatform ()) {
921
- auto canonicalizeVersion = [&](llvm::VersionTuple version) {
922
- return canonicalizePlatformVersion (domain->getPlatformKind (), version);
923
- };
924
- if (introducedVersion)
925
- mutableAttr->setRawIntroduced (canonicalizeVersion (*introducedVersion));
926
-
927
- if (deprecatedVersion)
928
- mutableAttr->setRawDeprecated (canonicalizeVersion (*deprecatedVersion));
929
-
930
- if (obsoletedVersion)
931
- mutableAttr->setRawObsoleted (canonicalizeVersion (*obsoletedVersion));
932
- }
933
-
934
917
return semanticAttr;
935
918
}
936
919
920
+ std::optional<llvm::VersionTuple> SemanticAvailableAttr::getIntroduced () const {
921
+ if (auto version = attr->getRawIntroduced ())
922
+ return canonicalizePlatformVersion (getPlatform (), *version);
923
+ return std::nullopt;
924
+ }
925
+
937
926
AvailabilityRange
938
927
SemanticAvailableAttr::getIntroducedRange (const ASTContext &Ctx) const {
939
928
assert (getDomain ().isActive (Ctx));
@@ -942,7 +931,7 @@ SemanticAvailableAttr::getIntroducedRange(const ASTContext &Ctx) const {
942
931
if (!attr->getRawIntroduced ().has_value ())
943
932
return AvailabilityRange::alwaysAvailable ();
944
933
945
- llvm::VersionTuple IntroducedVersion = attr-> getRawIntroduced ().value ();
934
+ llvm::VersionTuple IntroducedVersion = getIntroduced ().value ();
946
935
StringRef Platform;
947
936
llvm::VersionTuple RemappedIntroducedVersion;
948
937
if (AvailabilityInference::updateIntroducedPlatformForFallback (
@@ -952,6 +941,18 @@ SemanticAvailableAttr::getIntroducedRange(const ASTContext &Ctx) const {
952
941
return AvailabilityRange{VersionRange::allGTE (IntroducedVersion)};
953
942
}
954
943
944
+ std::optional<llvm::VersionTuple> SemanticAvailableAttr::getDeprecated () const {
945
+ if (auto version = attr->getRawDeprecated ())
946
+ return canonicalizePlatformVersion (getPlatform (), *version);
947
+ return std::nullopt;
948
+ }
949
+
950
+ std::optional<llvm::VersionTuple> SemanticAvailableAttr::getObsoleted () const {
951
+ if (auto version = attr->getRawObsoleted ())
952
+ return canonicalizePlatformVersion (getPlatform (), *version);
953
+ return std::nullopt;
954
+ }
955
+
955
956
namespace {
956
957
// / Infers the availability required to access a type.
957
958
class AvailabilityInferenceTypeWalker : public TypeWalker {
0 commit comments