@@ -712,29 +712,6 @@ TypeChecker::overApproximateAvailabilityAtLocation(SourceLoc loc,
712
712
return OverApproximateContext;
713
713
}
714
714
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
-
738
715
Optional<UnavailabilityReason>
739
716
TypeChecker::checkDeclarationAvailability (const Decl *D, SourceLoc referenceLoc,
740
717
const DeclContext *referenceDC) {
@@ -749,12 +726,20 @@ TypeChecker::checkDeclarationAvailability(const Decl *D, SourceLoc referenceLoc,
749
726
return None;
750
727
}
751
728
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))
754
741
return None;
755
- }
756
742
757
- // safeRangeUnderApprox now holds the safe range.
758
743
VersionRange version = safeRangeUnderApprox.getOSVersion ();
759
744
return UnavailabilityReason::requiresVersionRange (version);
760
745
}
0 commit comments