Skip to content

AST: Rename the ResilienceBoundary to APIBoundary in TypeRefinementContext::Reason #58733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions include/swift/AST/TypeRefinementContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ class TypeRefinementContext : public ASTAllocated<TypeRefinementContext> {
/// function declaration or the contents of a class declaration).
Decl,

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

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

Decl *getAsDecl() const {
assert(IntroReason == Reason::Decl ||
IntroReason == Reason::ResilienceBoundary);
assert(IntroReason == Reason::Decl || IntroReason == Reason::APIBoundary);
return D;
}

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

/// Create a refinement context for the given declaration.
static TypeRefinementContext *
createForResilienceBoundary(ASTContext &Ctx, Decl *D,
TypeRefinementContext *Parent,
const AvailabilityContext &Info,
SourceRange SrcRange);
createForAPIBoundary(ASTContext &Ctx, Decl *D, TypeRefinementContext *Parent,
const AvailabilityContext &Info, SourceRange SrcRange);

/// Create a refinement context for the Then branch of the given IfStmt.
static TypeRefinementContext *
Expand Down
27 changes: 11 additions & 16 deletions lib/AST/TypeRefinementContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,14 @@ TypeRefinementContext::createForDecl(ASTContext &Ctx, Decl *D,
TypeRefinementContext(Ctx, D, Parent, SrcRange, Info, ExplicitInfo);
}

TypeRefinementContext *
TypeRefinementContext::createForResilienceBoundary(ASTContext &Ctx, Decl *D,
TypeRefinementContext *Parent,
const AvailabilityContext &Info,
SourceRange SrcRange) {
TypeRefinementContext *TypeRefinementContext::createForAPIBoundary(
ASTContext &Ctx, Decl *D, TypeRefinementContext *Parent,
const AvailabilityContext &Info, SourceRange SrcRange) {
assert(D);
assert(Parent);
return new (Ctx)
TypeRefinementContext(Ctx, IntroNode(D, Reason::ResilienceBoundary),
Parent, SrcRange, Info,
AvailabilityContext::alwaysAvailable());

return new (Ctx) TypeRefinementContext(
Ctx, IntroNode(D, Reason::APIBoundary), Parent, SrcRange, Info,
AvailabilityContext::alwaysAvailable());
}

TypeRefinementContext *
Expand Down Expand Up @@ -184,7 +180,7 @@ void TypeRefinementContext::dump(raw_ostream &OS, SourceManager &SrcMgr) const {
SourceLoc TypeRefinementContext::getIntroductionLoc() const {
switch (getReason()) {
case Reason::Decl:
case Reason::ResilienceBoundary:
case Reason::APIBoundary:
return Node.getAsDecl()->getLoc();

case Reason::IfStmtThenBranch:
Expand Down Expand Up @@ -298,7 +294,7 @@ TypeRefinementContext::getAvailabilityConditionVersionSourceRange(
Node.getAsWhileStmt()->getCond(), Platform, Version);

case Reason::Root:
case Reason::ResilienceBoundary:
case Reason::APIBoundary:
return SourceRange();
}

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

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

if (getReason() == Reason::Decl
|| getReason() == Reason::ResilienceBoundary) {
if (getReason() == Reason::Decl || getReason() == Reason::APIBoundary) {
Decl *D = Node.getAsDecl();
OS << " decl=";
if (auto VD = dyn_cast<ValueDecl>(D)) {
Expand Down Expand Up @@ -355,8 +350,8 @@ StringRef TypeRefinementContext::getReasonName(Reason R) {
case Reason::Decl:
return "decl";

case Reason::ResilienceBoundary:
return "resilience_boundary";
case Reason::APIBoundary:
return "api_boundary";

case Reason::IfStmtThenBranch:
return "if_then";
Expand Down
11 changes: 4 additions & 7 deletions lib/Sema/TypeCheckAvailability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,8 @@ class TypeRefinementContextBuilder : private ASTWalker {
DeclInfo, ExplicitDeclInfo,
Range);
else
NewTRC =
TypeRefinementContext::createForResilienceBoundary(Context, D,
getCurrentTRC(),
DeclInfo, Range);
NewTRC = TypeRefinementContext::createForAPIBoundary(
Context, D, getCurrentTRC(), DeclInfo, Range);

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

return TypeRefinementContext::createForResilienceBoundary(
Context, D, getCurrentTRC(),
DeploymentTargetInfo, range);
return TypeRefinementContext::createForAPIBoundary(
Context, D, getCurrentTRC(), DeploymentTargetInfo, range);
}

std::pair<bool, Stmt *> walkToStmtPre(Stmt *S) override {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
// CHECK-tvos: {{^}}(root versions=[9.0,+Inf)
// CHECK-watchos: {{^}}(root versions=[2.0,+Inf)

// CHECK-macosx-NEXT: {{^}} (resilience_boundary versions=[10.15.0,+Inf) decl=foo()
// CHECK-ios-NEXT: {{^}} (resilience_boundary versions=[13.0.0,+Inf) decl=foo()
// CHECK-tvos-NEXT: {{^}} (resilience_boundary versions=[13.0.0,+Inf) decl=foo()
// CHECK-watchos-NEXT: {{^}} (resilience_boundary versions=[6.0.0,+Inf) decl=foo()
// CHECK-macosx-NEXT: {{^}} (api_boundary versions=[10.15.0,+Inf) decl=foo()
// CHECK-ios-NEXT: {{^}} (api_boundary versions=[13.0.0,+Inf) decl=foo()
// CHECK-tvos-NEXT: {{^}} (api_boundary versions=[13.0.0,+Inf) decl=foo()
// CHECK-watchos-NEXT: {{^}} (api_boundary versions=[6.0.0,+Inf) decl=foo()
func foo() {}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
// Verify that -target-min-inlining-version min implies 13.1 on macCatalyst.

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