Skip to content

Commit 1945c37

Browse files
committed
Sema: Retire some ExportContext availability conveniences.
Just use the `AvailabilityContext` directly.
1 parent 44ab007 commit 1945c37

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,18 +1488,19 @@ static void diagnoseIfDeprecated(SourceRange ReferenceRange,
14881488
if (!Attr)
14891489
return;
14901490

1491+
auto Availability = Where.getAvailability();
1492+
14911493
// We match the behavior of clang to not report deprecation warnings
14921494
// inside declarations that are themselves deprecated on all deployment
14931495
// targets.
1494-
if (Where.isDeprecated()) {
1496+
if (Availability.isDeprecated()) {
14951497
return;
14961498
}
14971499

14981500
auto *ReferenceDC = Where.getDeclContext();
14991501
auto &Context = ReferenceDC->getASTContext();
15001502
if (!Context.LangOpts.DisableAvailabilityChecking) {
1501-
AvailabilityRange RunningOSVersions = Where.getAvailabilityRange();
1502-
if (RunningOSVersions.isKnownUnreachable()) {
1503+
if (Availability.getPlatformRange().isKnownUnreachable()) {
15031504
// Suppress a deprecation warning if the availability checking machinery
15041505
// thinks the reference program location will not execute on any
15051506
// deployment target for the current platform.
@@ -1567,18 +1568,19 @@ static bool diagnoseIfDeprecated(SourceLoc loc,
15671568
if (!attr)
15681569
return false;
15691570

1571+
auto availability = where.getAvailability();
1572+
15701573
// We match the behavior of clang to not report deprecation warnings
15711574
// inside declarations that are themselves deprecated on all deployment
15721575
// targets.
1573-
if (where.isDeprecated()) {
1576+
if (availability.isDeprecated()) {
15741577
return false;
15751578
}
15761579

15771580
auto *dc = where.getDeclContext();
15781581
auto &ctx = dc->getASTContext();
15791582
if (!ctx.LangOpts.DisableAvailabilityChecking) {
1580-
AvailabilityRange runningOSVersion = where.getAvailabilityRange();
1581-
if (runningOSVersion.isKnownUnreachable()) {
1583+
if (availability.getPlatformRange().isKnownUnreachable()) {
15821584
// Suppress a deprecation warning if the availability checking machinery
15831585
// thinks the reference program location will not execute on any
15841586
// deployment target for the current platform.

lib/Sema/TypeCheckAvailability.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,6 @@ class ExportContext {
164164

165165
AvailabilityContext getAvailability() const { return Availability; }
166166

167-
AvailabilityRange getAvailabilityRange() const {
168-
return Availability.getPlatformRange();
169-
}
170-
171167
/// If not 'None', the context has the inlinable function body restriction.
172168
FragileFunctionKind getFragileFunctionKind() const { return FragileKind; }
173169

@@ -188,10 +184,6 @@ class ExportContext {
188184
/// or declarations from `@_implementationOnly` imports.
189185
bool isExported() const { return Exported; }
190186

191-
/// If true, the context is part of a deprecated declaration and can
192-
/// reference other deprecated declarations without warning.
193-
bool isDeprecated() const { return Availability.isDeprecated(); }
194-
195187
/// If true, the context can only reference exported declarations, either
196188
/// because it is the signature context of an exported declaration, or
197189
/// because it is the function body context of an inlinable function.

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1904,7 +1904,7 @@ RequirementCheck WitnessChecker::checkWitness(ValueDecl *requirement,
19041904
isDefaultWitness = isa<ProtocolDecl>(nominal);
19051905
if (isDefaultWitness && match.Witness->isDeprecated() &&
19061906
!requirement->isDeprecated()) {
1907-
auto conformanceContext = ExportContext::forConformance(DC, Proto);
1907+
auto conformanceContext = AvailabilityContext::forDeclSignature(DC->getInnermostDeclarationDeclContext());
19081908
if (!conformanceContext.isDeprecated()) {
19091909
return RequirementCheck(CheckKind::DefaultWitnessDeprecated);
19101910
}

0 commit comments

Comments
 (0)