Skip to content

Commit b6b492d

Browse files
committed
[CS] Rename LocatorPathElt::Requirement
Rename to LocatorPathElt::ProtocolRequirement in order to help avoid confusion with LocatorPathElt::AnyRequirement.
1 parent 6d8b798 commit b6b492d

File tree

5 files changed

+21
-19
lines changed

5 files changed

+21
-19
lines changed

lib/Sema/ConstraintLocator.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ void ConstraintLocator::Profile(llvm::FoldingSetNodeID &id, Expr *anchor,
3737
id.AddPointer(elt.castTo<LocatorPathElt::GenericParameter>().getType());
3838
break;
3939

40-
case Requirement:
41-
id.AddPointer(elt.castTo<LocatorPathElt::Requirement>().getDecl());
40+
case ProtocolRequirement: {
41+
auto reqElt = elt.castTo<LocatorPathElt::ProtocolRequirement>();
42+
id.AddPointer(reqElt.getDecl());
4243
break;
44+
}
4345

4446
case Witness:
4547
id.AddPointer(elt.castTo<LocatorPathElt::Witness>().getDecl());
@@ -338,9 +340,9 @@ void ConstraintLocator::dump(SourceManager *sm, raw_ostream &out) {
338340
out << "key path component #" << llvm::utostr(kpElt.getIndex());
339341
break;
340342
}
341-
case Requirement: {
342-
auto reqElt = elt.castTo<LocatorPathElt::Requirement>();
343-
out << "requirement ";
343+
case ProtocolRequirement: {
344+
auto reqElt = elt.castTo<LocatorPathElt::ProtocolRequirement>();
345+
out << "protocol requirement ";
344346
reqElt.getDecl()->dumpRef(out);
345347
break;
346348
}

lib/Sema/ConstraintLocator.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class ConstraintLocator : public llvm::FoldingSetNode {
8181
case ExistentialSuperclassType:
8282
case SequenceElementType:
8383
case AutoclosureResult:
84-
case Requirement:
84+
case ProtocolRequirement:
8585
case Witness:
8686
case ImplicitlyUnwrappedDisjunctionChoice:
8787
case DynamicLookupResult:
@@ -148,7 +148,7 @@ class ConstraintLocator : public llvm::FoldingSetNode {
148148
case GenericArgument:
149149
case NamedTupleElement:
150150
case TupleElement:
151-
case Requirement:
151+
case ProtocolRequirement:
152152
case Witness:
153153
case KeyPathComponent:
154154
case ConditionalRequirement:
@@ -179,7 +179,7 @@ class ConstraintLocator : public llvm::FoldingSetNode {
179179
/// Describes the kind of data stored here.
180180
enum StoredKind : unsigned char {
181181
StoredGenericParameter,
182-
StoredRequirement,
182+
StoredProtocolRequirement,
183183
StoredWitness,
184184
StoredGenericSignature,
185185
StoredKeyPathDynamicMemberBase,
@@ -291,8 +291,8 @@ class ConstraintLocator : public llvm::FoldingSetNode {
291291
case StoredGenericParameter:
292292
return PathElementKind::GenericParameter;
293293

294-
case StoredRequirement:
295-
return PathElementKind::Requirement;
294+
case StoredProtocolRequirement:
295+
return PathElementKind::ProtocolRequirement;
296296

297297
case StoredWitness:
298298
return PathElementKind::Witness;
@@ -788,15 +788,15 @@ class LocatorPathElt::Witness final : public LocatorPathElt {
788788
}
789789
};
790790

791-
class LocatorPathElt::Requirement final : public LocatorPathElt {
791+
class LocatorPathElt::ProtocolRequirement final : public LocatorPathElt {
792792
public:
793-
Requirement(ValueDecl *decl)
794-
: LocatorPathElt(LocatorPathElt::StoredRequirement, decl) {}
793+
ProtocolRequirement(ValueDecl *decl)
794+
: LocatorPathElt(LocatorPathElt::StoredProtocolRequirement, decl) {}
795795

796796
ValueDecl *getDecl() const { return getStoredPointer<ValueDecl>(); }
797797

798798
static bool classof(const LocatorPathElt *elt) {
799-
return elt->getKind() == ConstraintLocator::Requirement;
799+
return elt->getKind() == ConstraintLocator::ProtocolRequirement;
800800
}
801801
};
802802

lib/Sema/ConstraintLocatorPathElts.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ SIMPLE_LOCATOR_PATH_ELT(ParentType)
128128

129129
/// The requirement that we're matching during protocol conformance
130130
/// checking.
131-
CUSTOM_LOCATOR_PATH_ELT(Requirement)
131+
CUSTOM_LOCATOR_PATH_ELT(ProtocolRequirement)
132132

133133
/// Type parameter requirements.
134134
ABSTRACT_LOCATOR_PATH_ELT(AnyRequirement)

lib/Sema/ConstraintSystem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,8 +1206,8 @@ static void addSelfConstraint(ConstraintSystem &cs, Type objectTy, Type selfTy,
12061206
/// Determine whether the given locator is for a witness or requirement.
12071207
static bool isRequirementOrWitness(const ConstraintLocatorBuilder &locator) {
12081208
if (auto last = locator.last()) {
1209-
return last->getKind() == ConstraintLocator::Requirement ||
1210-
last->getKind() == ConstraintLocator::Witness;
1209+
return last->getKind() == ConstraintLocator::ProtocolRequirement ||
1210+
last->getKind() == ConstraintLocator::Witness;
12111211
}
12121212

12131213
return false;

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,8 +724,8 @@ swift::matchWitness(TypeChecker &tc,
724724
selfTy = reqGenericEnv->mapTypeIntoContext(selfTy);
725725

726726
// Open up the type of the requirement.
727-
reqLocator = cs->getConstraintLocator(static_cast<Expr *>(nullptr),
728-
LocatorPathElt::Requirement(req));
727+
reqLocator = cs->getConstraintLocator(
728+
static_cast<Expr *>(nullptr), LocatorPathElt::ProtocolRequirement(req));
729729
OpenedTypeMap reqReplacements;
730730
std::tie(openedFullReqType, reqType)
731731
= cs->getTypeOfMemberReference(selfTy, req, dc,

0 commit comments

Comments
 (0)