@@ -1896,7 +1896,8 @@ void AttributeChecker::visitAvailableAttr(AvailableAttr *attr) {
1896
1896
}
1897
1897
1898
1898
// Skip the remaining diagnostics in swiftinterfaces.
1899
- auto *SF = D->getDeclContext ()->getParentSourceFile ();
1899
+ auto *DC = D->getDeclContext ();
1900
+ auto *SF = DC->getParentSourceFile ();
1900
1901
if (SF && SF->Kind == SourceFileKind::Interface)
1901
1902
return ;
1902
1903
@@ -1926,7 +1927,7 @@ void AttributeChecker::visitAvailableAttr(AvailableAttr *attr) {
1926
1927
return ;
1927
1928
}
1928
1929
1929
- if (auto *PD = dyn_cast<ProtocolDecl>(D-> getDeclContext () )) {
1930
+ if (auto *PD = dyn_cast<ProtocolDecl>(DC )) {
1930
1931
if (auto *VD = dyn_cast<ValueDecl>(D)) {
1931
1932
if (VD->isProtocolRequirement () && !PD->isObjC ()) {
1932
1933
diagnoseAndRemoveAttr (attr,
@@ -1958,13 +1959,17 @@ void AttributeChecker::visitAvailableAttr(AvailableAttr *attr) {
1958
1959
EnclosingAnnotatedRange.emplace (
1959
1960
AvailabilityInference::availableRange (enclosingAttr, Ctx));
1960
1961
if (!AttrRange.isContainedIn (*EnclosingAnnotatedRange)) {
1961
- // Members of extensions of nominal types with available ranges were
1962
- // not diagnosed previously, so only emit a warning in that case.
1963
- bool inExtension = isa<ExtensionDecl>(
1964
- D->getDeclContext ()->getTopmostDeclarationDeclContext ());
1965
- auto limit = (enclosingDecl != parent && inExtension)
1966
- ? DiagnosticBehavior::Warning
1967
- : DiagnosticBehavior::Unspecified;
1962
+ auto limit = DiagnosticBehavior::Unspecified;
1963
+ if (D->isImplicit ()) {
1964
+ // Incorrect availability for an implicit declaration is likely a
1965
+ // compiler bug so make the diagnostic a warning.
1966
+ limit = DiagnosticBehavior::Warning;
1967
+ } else if (enclosingDecl != parent) {
1968
+ // Members of extensions of nominal types with available ranges were
1969
+ // not diagnosed previously, so only emit a warning in that case.
1970
+ if (isa<ExtensionDecl>(DC->getTopmostDeclarationDeclContext ()))
1971
+ limit = DiagnosticBehavior::Warning;
1972
+ }
1968
1973
diagnose (D->isImplicit () ? enclosingDecl->getLoc ()
1969
1974
: attr->getLocation (),
1970
1975
diag::availability_decl_more_than_enclosing,
0 commit comments