mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Sema] Diagnose internal(set) from @inlinable functions
This patch mainly consolidates the functions used to check accessors vs. other decls, and makes sure we check setter access as well as regular decl access. rdar://45217648
This commit is contained in:
@@ -134,21 +134,37 @@ bool TypeChecker::diagnoseInlinableDeclRef(SourceLoc loc,
|
||||
downgradeToWarning = DowngradeToWarning::Yes;
|
||||
}
|
||||
|
||||
auto diagName = D->getFullName();
|
||||
bool isAccessor = false;
|
||||
|
||||
// Swift 4.2 did not check accessor accessiblity.
|
||||
if (auto accessor = dyn_cast<AccessorDecl>(D)) {
|
||||
isAccessor = true;
|
||||
|
||||
if (!Context.isSwiftVersionAtLeast(5))
|
||||
downgradeToWarning = DowngradeToWarning::Yes;
|
||||
|
||||
// For accessors, diagnose with the name of the storage instead of the
|
||||
// implicit '_'.
|
||||
diagName = accessor->getStorage()->getFullName();
|
||||
}
|
||||
|
||||
auto diagID = diag::resilience_decl_unavailable;
|
||||
if (downgradeToWarning == DowngradeToWarning::Yes)
|
||||
diagID = diag::resilience_decl_unavailable_warn;
|
||||
|
||||
diagnose(loc, diagID,
|
||||
D->getDescriptiveKind(), D->getFullName(),
|
||||
D->getDescriptiveKind(), diagName,
|
||||
D->getFormalAccessScope().accessLevelForDiagnostics(),
|
||||
static_cast<unsigned>(Kind));
|
||||
static_cast<unsigned>(Kind),
|
||||
isAccessor);
|
||||
|
||||
if (TreatUsableFromInlineAsPublic) {
|
||||
diagnose(D, diag::resilience_decl_declared_here,
|
||||
D->getDescriptiveKind(), D->getFullName());
|
||||
D->getDescriptiveKind(), diagName, isAccessor);
|
||||
} else {
|
||||
diagnose(D, diag::resilience_decl_declared_here_public,
|
||||
D->getDescriptiveKind(), D->getFullName());
|
||||
D->getDescriptiveKind(), diagName, isAccessor);
|
||||
}
|
||||
|
||||
return (downgradeToWarning == DowngradeToWarning::No);
|
||||
|
||||
Reference in New Issue
Block a user