@@ -712,29 +712,6 @@ TypeChecker::overApproximateAvailabilityAtLocation(SourceLoc loc,
712712 return OverApproximateContext;
713713}
714714
715- bool TypeChecker::isDeclAvailable (const Decl *D, SourceLoc referenceLoc,
716- const DeclContext *referenceDC,
717- AvailabilityContext &OutAvailableInfo) {
718- ASTContext &Context = referenceDC->getASTContext ();
719-
720- AvailabilityContext safeRangeUnderApprox{
721- AvailabilityInference::availableRange (D, Context)};
722- AvailabilityContext runningOSOverApprox =
723- overApproximateAvailabilityAtLocation (referenceLoc, referenceDC);
724-
725- // The reference is safe if an over-approximation of the running OS
726- // versions is fully contained within an under-approximation
727- // of the versions on which the declaration is available. If this
728- // containment cannot be guaranteed, we say the reference is
729- // not available.
730- if (!(runningOSOverApprox.isContainedIn (safeRangeUnderApprox))) {
731- OutAvailableInfo = safeRangeUnderApprox;
732- return false ;
733- }
734-
735- return true ;
736- }
737-
738715Optional<UnavailabilityReason>
739716TypeChecker::checkDeclarationAvailability (const Decl *D, SourceLoc referenceLoc,
740717 const DeclContext *referenceDC) {
@@ -749,12 +726,20 @@ TypeChecker::checkDeclarationAvailability(const Decl *D, SourceLoc referenceLoc,
749726 return None;
750727 }
751728
752- auto safeRangeUnderApprox = AvailabilityContext::neverAvailable ();
753- if (isDeclAvailable (D, referenceLoc, referenceDC, safeRangeUnderApprox)) {
729+ AvailabilityContext runningOSOverApprox =
730+ overApproximateAvailabilityAtLocation (referenceLoc, referenceDC);
731+
732+ AvailabilityContext safeRangeUnderApprox{
733+ AvailabilityInference::availableRange (D, Context)};
734+
735+ // The reference is safe if an over-approximation of the running OS
736+ // versions is fully contained within an under-approximation
737+ // of the versions on which the declaration is available. If this
738+ // containment cannot be guaranteed, we say the reference is
739+ // not available.
740+ if (runningOSOverApprox.isContainedIn (safeRangeUnderApprox))
754741 return None;
755- }
756742
757- // safeRangeUnderApprox now holds the safe range.
758743 VersionRange version = safeRangeUnderApprox.getOSVersion ();
759744 return UnavailabilityReason::requiresVersionRange (version);
760745}
0 commit comments