Skip to content

Commit 537312c

Browse files
authored
Merge pull request #58733 from tshortli/rename-trc-resilience-boundary-to-api-boundary
AST: Rename the `ResilienceBoundary` to `APIBoundary` in `TypeRefinementContext::Reason`
2 parents a1a5038 + 5ad00f6 commit 537312c

5 files changed

+25
-36
lines changed

include/swift/AST/TypeRefinementContext.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ class TypeRefinementContext : public ASTAllocated<TypeRefinementContext> {
5858
/// function declaration or the contents of a class declaration).
5959
Decl,
6060

61-
/// The context was introduced by a resilience boundary; that is, we are in
61+
/// The context was introduced by an API boundary; that is, we are in
6262
/// a module with library evolution enabled and the parent context's
6363
/// contents can be visible to the module's clients, but this context's
6464
/// contents are not.
65-
ResilienceBoundary,
65+
APIBoundary,
6666

6767
/// The context was introduced for the Then branch of an IfStmt.
6868
IfStmtThenBranch,
@@ -131,8 +131,7 @@ class TypeRefinementContext : public ASTAllocated<TypeRefinementContext> {
131131
}
132132

133133
Decl *getAsDecl() const {
134-
assert(IntroReason == Reason::Decl ||
135-
IntroReason == Reason::ResilienceBoundary);
134+
assert(IntroReason == Reason::Decl || IntroReason == Reason::APIBoundary);
136135
return D;
137136
}
138137

@@ -195,10 +194,8 @@ class TypeRefinementContext : public ASTAllocated<TypeRefinementContext> {
195194

196195
/// Create a refinement context for the given declaration.
197196
static TypeRefinementContext *
198-
createForResilienceBoundary(ASTContext &Ctx, Decl *D,
199-
TypeRefinementContext *Parent,
200-
const AvailabilityContext &Info,
201-
SourceRange SrcRange);
197+
createForAPIBoundary(ASTContext &Ctx, Decl *D, TypeRefinementContext *Parent,
198+
const AvailabilityContext &Info, SourceRange SrcRange);
202199

203200
/// Create a refinement context for the Then branch of the given IfStmt.
204201
static TypeRefinementContext *

lib/AST/TypeRefinementContext.cpp

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,14 @@ TypeRefinementContext::createForDecl(ASTContext &Ctx, Decl *D,
6464
TypeRefinementContext(Ctx, D, Parent, SrcRange, Info, ExplicitInfo);
6565
}
6666

67-
TypeRefinementContext *
68-
TypeRefinementContext::createForResilienceBoundary(ASTContext &Ctx, Decl *D,
69-
TypeRefinementContext *Parent,
70-
const AvailabilityContext &Info,
71-
SourceRange SrcRange) {
67+
TypeRefinementContext *TypeRefinementContext::createForAPIBoundary(
68+
ASTContext &Ctx, Decl *D, TypeRefinementContext *Parent,
69+
const AvailabilityContext &Info, SourceRange SrcRange) {
7270
assert(D);
7371
assert(Parent);
74-
return new (Ctx)
75-
TypeRefinementContext(Ctx, IntroNode(D, Reason::ResilienceBoundary),
76-
Parent, SrcRange, Info,
77-
AvailabilityContext::alwaysAvailable());
78-
72+
return new (Ctx) TypeRefinementContext(
73+
Ctx, IntroNode(D, Reason::APIBoundary), Parent, SrcRange, Info,
74+
AvailabilityContext::alwaysAvailable());
7975
}
8076

8177
TypeRefinementContext *
@@ -184,7 +180,7 @@ void TypeRefinementContext::dump(raw_ostream &OS, SourceManager &SrcMgr) const {
184180
SourceLoc TypeRefinementContext::getIntroductionLoc() const {
185181
switch (getReason()) {
186182
case Reason::Decl:
187-
case Reason::ResilienceBoundary:
183+
case Reason::APIBoundary:
188184
return Node.getAsDecl()->getLoc();
189185

190186
case Reason::IfStmtThenBranch:
@@ -298,7 +294,7 @@ TypeRefinementContext::getAvailabilityConditionVersionSourceRange(
298294
Node.getAsWhileStmt()->getCond(), Platform, Version);
299295

300296
case Reason::Root:
301-
case Reason::ResilienceBoundary:
297+
case Reason::APIBoundary:
302298
return SourceRange();
303299
}
304300

@@ -312,8 +308,7 @@ void TypeRefinementContext::print(raw_ostream &OS, SourceManager &SrcMgr,
312308

313309
OS << " versions=" << AvailabilityInfo.getOSVersion().getAsString();
314310

315-
if (getReason() == Reason::Decl
316-
|| getReason() == Reason::ResilienceBoundary) {
311+
if (getReason() == Reason::Decl || getReason() == Reason::APIBoundary) {
317312
Decl *D = Node.getAsDecl();
318313
OS << " decl=";
319314
if (auto VD = dyn_cast<ValueDecl>(D)) {
@@ -355,8 +350,8 @@ StringRef TypeRefinementContext::getReasonName(Reason R) {
355350
case Reason::Decl:
356351
return "decl";
357352

358-
case Reason::ResilienceBoundary:
359-
return "resilience_boundary";
353+
case Reason::APIBoundary:
354+
return "api_boundary";
360355

361356
case Reason::IfStmtThenBranch:
362357
return "if_then";

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -543,10 +543,8 @@ class TypeRefinementContextBuilder : private ASTWalker {
543543
DeclInfo, ExplicitDeclInfo,
544544
Range);
545545
else
546-
NewTRC =
547-
TypeRefinementContext::createForResilienceBoundary(Context, D,
548-
getCurrentTRC(),
549-
DeclInfo, Range);
546+
NewTRC = TypeRefinementContext::createForAPIBoundary(
547+
Context, D, getCurrentTRC(), DeclInfo, Range);
550548

551549
// Possibly use this as an effective parent context later.
552550
recordEffectiveParentContext(D, NewTRC);
@@ -677,9 +675,8 @@ class TypeRefinementContextBuilder : private ASTWalker {
677675
AvailabilityContext::forDeploymentTarget(Context);
678676
DeploymentTargetInfo.intersectWith(getCurrentTRC()->getAvailabilityInfo());
679677

680-
return TypeRefinementContext::createForResilienceBoundary(
681-
Context, D, getCurrentTRC(),
682-
DeploymentTargetInfo, range);
678+
return TypeRefinementContext::createForAPIBoundary(
679+
Context, D, getCurrentTRC(), DeploymentTargetInfo, range);
683680
}
684681

685682
std::pair<bool, Stmt *> walkToStmtPre(Stmt *S) override {

test/Sema/availability_refinement_contexts_target_min_inlining.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
// CHECK-tvos: {{^}}(root versions=[9.0,+Inf)
1212
// CHECK-watchos: {{^}}(root versions=[2.0,+Inf)
1313

14-
// CHECK-macosx-NEXT: {{^}} (resilience_boundary versions=[10.15.0,+Inf) decl=foo()
15-
// CHECK-ios-NEXT: {{^}} (resilience_boundary versions=[13.0.0,+Inf) decl=foo()
16-
// CHECK-tvos-NEXT: {{^}} (resilience_boundary versions=[13.0.0,+Inf) decl=foo()
17-
// CHECK-watchos-NEXT: {{^}} (resilience_boundary versions=[6.0.0,+Inf) decl=foo()
14+
// CHECK-macosx-NEXT: {{^}} (api_boundary versions=[10.15.0,+Inf) decl=foo()
15+
// CHECK-ios-NEXT: {{^}} (api_boundary versions=[13.0.0,+Inf) decl=foo()
16+
// CHECK-tvos-NEXT: {{^}} (api_boundary versions=[13.0.0,+Inf) decl=foo()
17+
// CHECK-watchos-NEXT: {{^}} (api_boundary versions=[6.0.0,+Inf) decl=foo()
1818
func foo() {}

test/Sema/availability_refinement_contexts_target_min_inlining_maccatalyst.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
// Verify that -target-min-inlining-version min implies 13.1 on macCatalyst.
1212

1313
// CHECK: {{^}}(root versions=[13.1,+Inf)
14-
// CHECK-NEXT: {{^}} (resilience_boundary versions=[14.4.0,+Inf) decl=foo()
14+
// CHECK-NEXT: {{^}} (api_boundary versions=[14.4.0,+Inf) decl=foo()
1515
func foo() {}

0 commit comments

Comments
 (0)