Skip to content

Commit 0841b68

Browse files
committed
Sema: Retire ExportContext::shouldDiagnoseDeclAsUnavailable().
NFC.
1 parent 1d3dbef commit 0841b68

File tree

3 files changed

+6
-21
lines changed

3 files changed

+6
-21
lines changed

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -367,18 +367,6 @@ static bool isInsideCompatibleUnavailableDeclaration(
367367
return availabilityContext.containsUnavailableDomain(declDomain);
368368
}
369369

370-
std::optional<SemanticAvailableAttr>
371-
ExportContext::shouldDiagnoseDeclAsUnavailable(const Decl *D) const {
372-
auto attr = D->getUnavailableAttr();
373-
if (!attr)
374-
return std::nullopt;
375-
376-
if (isInsideCompatibleUnavailableDeclaration(D, Availability, *attr))
377-
return std::nullopt;
378-
379-
return attr;
380-
}
381-
382370
static bool shouldAllowReferenceToUnavailableInSwiftDeclaration(
383371
const Decl *D, const ExportContext &where) {
384372
auto *DC = where.getDeclContext();

lib/Sema/TypeCheckAvailability.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,6 @@ class ExportContext {
201201
/// Get the ExportabilityReason for diagnostics. If this is 'None', there
202202
/// are no restrictions on referencing unexported declarations.
203203
std::optional<ExportabilityReason> getExportabilityReason() const;
204-
205-
/// If \p decl is unconditionally unavailable in this context, and the context
206-
/// is not also unavailable in the same way, then this returns the specific
207-
/// `@available` attribute that makes the decl unavailable. Otherwise, returns
208-
/// nullptr.
209-
std::optional<SemanticAvailableAttr>
210-
shouldDiagnoseDeclAsUnavailable(const Decl *decl) const;
211204
};
212205

213206
/// Check if a declaration is exported as part of a module's external interface.

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4963,12 +4963,16 @@ static bool diagnoseTypeWitnessAvailability(
49634963
bool shouldError =
49644964
ctx.LangOpts.EffectiveLanguageVersion.isVersionAtLeast(warnBeforeVersion);
49654965

4966-
if (auto attr = where.shouldDiagnoseDeclAsUnavailable(witness)) {
4966+
auto constraint =
4967+
getAvailabilityConstraintsForDecl(witness, where.getAvailability())
4968+
.getPrimaryConstraint();
4969+
if (constraint && constraint->isUnavailable()) {
4970+
auto attr = constraint->getAttr();
49674971
ctx.addDelayedConformanceDiag(
49684972
conformance, shouldError,
49694973
[witness, assocType, attr](NormalProtocolConformance *conformance) {
49704974
SourceLoc loc = getLocForDiagnosingWitness(conformance, witness);
4971-
EncodedDiagnosticMessage encodedMessage(attr->getMessage());
4975+
EncodedDiagnosticMessage encodedMessage(attr.getMessage());
49724976
auto &ctx = conformance->getDeclContext()->getASTContext();
49734977
ctx.Diags
49744978
.diagnose(loc, diag::witness_unavailable, witness,

0 commit comments

Comments
 (0)