@@ -1513,13 +1513,6 @@ checkDeclarationAvailability(const Decl *D, const ExportContext &Where) {
1513
1513
return std::nullopt;
1514
1514
}
1515
1515
1516
- std::optional<AvailabilityRange>
1517
- TypeChecker::checkConformanceAvailability (const RootProtocolConformance *conf,
1518
- const ExtensionDecl *ext,
1519
- const ExportContext &where) {
1520
- return checkDeclarationAvailability (ext, where);
1521
- }
1522
-
1523
1516
// / A class that walks the AST to find the innermost (i.e., deepest) node that
1524
1517
// / contains a target SourceRange and matches a particular criterion.
1525
1518
// / This class finds the innermost nodes of interest by walking
@@ -4625,6 +4618,7 @@ swift::diagnoseConformanceAvailability(SourceLoc loc,
4625
4618
// Diagnose "missing" conformances where we needed a conformance but
4626
4619
// didn't have one.
4627
4620
auto *DC = where.getDeclContext ();
4621
+ auto &ctx = DC->getASTContext ();
4628
4622
if (auto builtinConformance = dyn_cast<BuiltinProtocolConformance>(rootConf)){
4629
4623
if (builtinConformance->isMissing ()) {
4630
4624
diagnoseMissingConformance (loc, builtinConformance->getType (),
@@ -4638,7 +4632,6 @@ swift::diagnoseConformanceAvailability(SourceLoc loc,
4638
4632
4639
4633
Type selfTy = rootConf->getProtocol ()->getSelfInterfaceType ();
4640
4634
if (!depTy->isEqual (selfTy)) {
4641
- auto &ctx = DC->getASTContext ();
4642
4635
ctx.Diags .diagnose (
4643
4636
loc,
4644
4637
diag::assoc_conformance_from_implementation_only_module,
@@ -4653,20 +4646,24 @@ swift::diagnoseConformanceAvailability(SourceLoc loc,
4653
4646
return true ;
4654
4647
}
4655
4648
4656
- if (diagnoseExplicitUnavailability (loc, rootConf, ext, where,
4657
- warnIfConformanceUnavailablePreSwift6)) {
4658
- maybeEmitAssociatedTypeNote ();
4659
- return true ;
4660
- }
4649
+ auto unmetRequirement = getUnmetDeclAvailabilityRequirement (
4650
+ ext, where.getDeclContext (), where.getAvailability ());
4651
+ if (unmetRequirement) {
4652
+ // FIXME: diagnoseExplicitUnavailability() should take unmet requirement
4653
+ if (diagnoseExplicitUnavailability (
4654
+ loc, rootConf, ext, where,
4655
+ warnIfConformanceUnavailablePreSwift6)) {
4656
+ maybeEmitAssociatedTypeNote ();
4657
+ return true ;
4658
+ }
4661
4659
4662
- // Diagnose (and possibly signal) for potential unavailability
4663
- auto maybeUnavail = TypeChecker::checkConformanceAvailability (
4664
- rootConf, ext, where);
4665
- if (maybeUnavail.has_value ()) {
4666
- diagnosePotentialUnavailability (rootConf, ext, loc, DC,
4667
- maybeUnavail.value ());
4668
- maybeEmitAssociatedTypeNote ();
4669
- return true ;
4660
+ // Diagnose (and possibly signal) for potential unavailability
4661
+ if (auto requiredRange =
4662
+ unmetRequirement->getRequiredNewerAvailabilityRange (ctx)) {
4663
+ diagnosePotentialUnavailability (rootConf, ext, loc, DC, *requiredRange);
4664
+ maybeEmitAssociatedTypeNote ();
4665
+ return true ;
4666
+ }
4670
4667
}
4671
4668
4672
4669
// Diagnose for deprecation
0 commit comments