@@ -824,9 +824,6 @@ SemanticAvailableAttrRequest::evaluate(swift::Evaluator &evaluator,
824824 auto attrLoc = attr->getLocation ();
825825 auto attrName = attr->getAttrName ();
826826 auto domainLoc = attr->getDomainLoc ();
827- auto introducedVersion = attr->getRawIntroduced ();
828- auto deprecatedVersion = attr->getRawDeprecated ();
829- auto obsoletedVersion = attr->getRawObsoleted ();
830827 auto mutableAttr = const_cast <AvailableAttr *>(attr);
831828 auto domain = attr->getCachedDomain ();
832829
@@ -867,16 +864,18 @@ SemanticAvailableAttrRequest::evaluate(swift::Evaluator &evaluator,
867864 auto domainName = domain->getNameForAttributePrinting ();
868865 auto semanticAttr = SemanticAvailableAttr (attr);
869866
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);
872871
873872 if (!domain->isVersioned () && hasVersionSpec) {
874873 SourceRange versionSourceRange;
875- if (introducedVersion )
874+ if (hasIntroduced )
876875 versionSourceRange = semanticAttr.getIntroducedSourceRange ();
877- else if (deprecatedVersion )
876+ else if (hasDeprecated )
878877 versionSourceRange = semanticAttr.getDeprecatedSourceRange ();
879- else if (obsoletedVersion )
878+ else if (hasObsoleted )
880879 versionSourceRange = semanticAttr.getObsoletedSourceRange ();
881880
882881 diags
@@ -915,25 +914,15 @@ SemanticAvailableAttrRequest::evaluate(swift::Evaluator &evaluator,
915914 }
916915 }
917916
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-
934917 return semanticAttr;
935918}
936919
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+
937926AvailabilityRange
938927SemanticAvailableAttr::getIntroducedRange (const ASTContext &Ctx) const {
939928 assert (getDomain ().isActive (Ctx));
@@ -942,7 +931,7 @@ SemanticAvailableAttr::getIntroducedRange(const ASTContext &Ctx) const {
942931 if (!attr->getRawIntroduced ().has_value ())
943932 return AvailabilityRange::alwaysAvailable ();
944933
945- llvm::VersionTuple IntroducedVersion = attr-> getRawIntroduced ().value ();
934+ llvm::VersionTuple IntroducedVersion = getIntroduced ().value ();
946935 StringRef Platform;
947936 llvm::VersionTuple RemappedIntroducedVersion;
948937 if (AvailabilityInference::updateIntroducedPlatformForFallback (
@@ -952,6 +941,18 @@ SemanticAvailableAttr::getIntroducedRange(const ASTContext &Ctx) const {
952941 return AvailabilityRange{VersionRange::allGTE (IntroducedVersion)};
953942}
954943
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+
955956namespace {
956957// / Infers the availability required to access a type.
957958class AvailabilityInferenceTypeWalker : public TypeWalker {
0 commit comments