Skip to content

Commit 7783f6b

Browse files
committed
[ConstraintSystem] Rename IsDeclSubstitutableRequest to
IsDeclRefinementOfRequest to better reflect what it computes.
1 parent 62305d0 commit 7783f6b

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

include/swift/AST/TypeCheckRequests.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,11 +1883,11 @@ class CompareDeclSpecializationRequest
18831883
bool isCached() const { return true; }
18841884
};
18851885

1886-
/// Checks whether substituting the first generic function decl with the
1887-
/// second generic function decl will satisfy all requirements and produce
1888-
/// the same function type.
1889-
class IsDeclSubstitutableRequest
1890-
: public SimpleRequest<IsDeclSubstitutableRequest,
1886+
/// Checks whether the first function decl is a refinement of the second,
1887+
/// meaning the two functions have the same structure, and the requirements
1888+
/// of the first are refining the requirements of the second.
1889+
class IsDeclRefinementOfRequest
1890+
: public SimpleRequest<IsDeclRefinementOfRequest,
18911891
bool(ValueDecl *, ValueDecl *),
18921892
RequestFlags::Cached> {
18931893
public:

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ SWIFT_REQUEST(TypeChecker, CodeCompletionFileRequest,
4141
SWIFT_REQUEST(TypeChecker, CompareDeclSpecializationRequest,
4242
bool (DeclContext *, ValueDecl *, ValueDecl *, bool), Cached,
4343
NoLocationInfo)
44-
SWIFT_REQUEST(TypeChecker, IsDeclSubstitutableRequest,
44+
SWIFT_REQUEST(TypeChecker, IsDeclRefinementOfRequest,
4545
bool (ValueDecl *, ValueDecl *),
4646
Cached, NoLocationInfo)
4747
SWIFT_REQUEST(TypeChecker, CustomAttrTypeRequest,

lib/Sema/CSSolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2197,7 +2197,7 @@ void ConstraintSystem::partitionDisjunction(
21972197
auto *declA = dyn_cast<ValueDecl>(Choices[lhs]->getOverloadChoice().getDecl());
21982198
auto *declB = dyn_cast<ValueDecl>(Choices[rhs]->getOverloadChoice().getDecl());
21992199

2200-
return TypeChecker::isDeclSubstitutable(declA, declB);
2200+
return TypeChecker::isDeclRefinementOf(declA, declB);
22012201
});
22022202

22032203
everythingElse.append(genericOverloads.begin(), genericOverloads.end());

lib/Sema/CSStep.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ StepResult DisjunctionStep::resume(bool prevFailed) {
530530
return take(prevFailed);
531531
}
532532

533-
bool IsDeclSubstitutableRequest::evaluate(Evaluator &evaluator,
533+
bool IsDeclRefinementOfRequest::evaluate(Evaluator &evaluator,
534534
ValueDecl *declA,
535535
ValueDecl *declB) const {
536536
auto *typeA = declA->getInterfaceType()->getAs<GenericFunctionType>();
@@ -574,9 +574,9 @@ bool IsDeclSubstitutableRequest::evaluate(Evaluator &evaluator,
574574
return substTypeA->isEqual(substTypeB);
575575
}
576576

577-
bool TypeChecker::isDeclSubstitutable(ValueDecl *declA, ValueDecl *declB) {
577+
bool TypeChecker::isDeclRefinementOf(ValueDecl *declA, ValueDecl *declB) {
578578
return evaluateOrDefault(declA->getASTContext().evaluator,
579-
IsDeclSubstitutableRequest{ declA, declB },
579+
IsDeclRefinementOfRequest{ declA, declB },
580580
false);
581581
}
582582

@@ -616,7 +616,7 @@ bool DisjunctionStep::shouldSkip(const DisjunctionChoice &choice) const {
616616
auto *declA = LastSolvedChoice->first->getOverloadChoice().getDecl();
617617
auto *declB = static_cast<Constraint *>(choice)->getOverloadChoice().getDecl();
618618

619-
if (TypeChecker::isDeclSubstitutable(declA, declB))
619+
if (TypeChecker::isDeclRefinementOf(declA, declB))
620620
return skip("subtype");
621621
}
622622

lib/Sema/TypeChecker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ Comparison compareDeclarations(DeclContext *dc, ValueDecl *decl1,
906906
/// Checks whether the first decl is a refinement of the second
907907
/// decl, meaning that the second decl can always be used in place
908908
/// of the first one and the expression will still type check.
909-
bool isDeclSubstitutable(ValueDecl *declA, ValueDecl *declB);
909+
bool isDeclRefinementOf(ValueDecl *declA, ValueDecl *declB);
910910

911911
/// Build a type-checked reference to the given value.
912912
Expr *buildCheckedRefExpr(VarDecl *D, DeclContext *UseDC, DeclNameLoc nameLoc,

0 commit comments

Comments
 (0)