Skip to content

Commit bbce384

Browse files
committed
Sema: Decouple availability checking from the TypeChecker
1 parent 040be29 commit bbce384

File tree

6 files changed

+153
-141
lines changed

6 files changed

+153
-141
lines changed

lib/Sema/MiscDiagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3961,7 +3961,7 @@ void swift::performSyntacticExprDiagnostics(TypeChecker &TC, const Expr *E,
39613961
if (!TC.Context.isSwiftVersionAtLeast(5))
39623962
diagnoseDeprecatedWritableKeyPath(TC, E, DC);
39633963
if (!TC.getLangOpts().DisableAvailabilityChecking)
3964-
diagAvailability(TC, E, const_cast<DeclContext*>(DC));
3964+
diagAvailability(E, const_cast<DeclContext*>(DC));
39653965
if (TC.Context.LangOpts.EnableObjCInterop)
39663966
diagDeprecatedObjCSelectors(TC, DC, E);
39673967
}

lib/Sema/ResilienceDiagnostics.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ bool TypeChecker::diagnoseInlinableDeclRefAccess(SourceLoc loc,
143143
TreatUsableFromInlineAsPublic).isPublic())
144144
return false;
145145

146+
auto &Context = DC->getASTContext();
147+
146148
// Dynamic declarations were mistakenly not checked in Swift 4.2.
147149
// Do enforce the restriction even in pre-Swift-5 modes if the module we're
148150
// building is resilient, though.
@@ -194,18 +196,19 @@ bool TypeChecker::diagnoseInlinableDeclRefAccess(SourceLoc loc,
194196
if (downgradeToWarning == DowngradeToWarning::Yes)
195197
diagID = diag::resilience_decl_unavailable_warn;
196198

197-
diagnose(loc, diagID,
199+
Context.Diags.diagnose(
200+
loc, diagID,
198201
D->getDescriptiveKind(), diagName,
199202
D->getFormalAccessScope().accessLevelForDiagnostics(),
200203
static_cast<unsigned>(Kind),
201204
isAccessor);
202205

203206
if (TreatUsableFromInlineAsPublic) {
204-
diagnose(D, diag::resilience_decl_declared_here,
205-
D->getDescriptiveKind(), diagName, isAccessor);
207+
Context.Diags.diagnose(D, diag::resilience_decl_declared_here,
208+
D->getDescriptiveKind(), diagName, isAccessor);
206209
} else {
207-
diagnose(D, diag::resilience_decl_declared_here_public,
208-
D->getDescriptiveKind(), diagName, isAccessor);
210+
Context.Diags.diagnose(D, diag::resilience_decl_declared_here_public,
211+
D->getDescriptiveKind(), diagName, isAccessor);
209212
}
210213

211214
return (downgradeToWarning == DowngradeToWarning::No);

0 commit comments

Comments
 (0)