Skip to content

Commit

Permalink
[Sema] Silence an inconsistent availability error for the stdlib
Browse files Browse the repository at this point in the history
Don't raise the error availability_decl_more_than_enclosing in the
context is unavailable and if read in a swiftinterface file. This error
was present in the stdlib in 5.3 without side effects so we still want
to accept it.
  • Loading branch information
xymus committed Oct 9, 2020
1 parent 25c9ddd commit f536a58
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/Sema/TypeCheckAttr.cpp
Expand Up @@ -1530,9 +1530,16 @@ void AttributeChecker::visitAvailableAttr(AvailableAttr *attr) {
VersionRange::allGTE(attr->Introduced.getValue())};

if (!AttrRange.isContainedIn(EnclosingAnnotatedRange.getValue())) {
diagnose(attr->getLocation(), diag::availability_decl_more_than_enclosing);
diagnose(EnclosingDecl->getLoc(),
diag::availability_decl_more_than_enclosing_enclosing_here);
// Don't show this error in swiftinterfaces if it is about a context that
// is unavailable, this was in the stdlib at Swift 5.3.
SourceFile *Parent = D->getDeclContext()->getParentSourceFile();
if (!Parent || Parent->Kind != SourceFileKind::Interface ||
!EnclosingAnnotatedRange.getValue().isKnownUnreachable()) {
diagnose(attr->getLocation(),
diag::availability_decl_more_than_enclosing);
diagnose(EnclosingDecl->getLoc(),
diag::availability_decl_more_than_enclosing_enclosing_here);
}
}
}

Expand Down

0 comments on commit f536a58

Please sign in to comment.