Skip to content

Commit 760d4be

Browse files
committed
[ConstraintSystem] Add a KeyPathComponentResult locator path element
We’ll use this instead of the function result, except for subscript components, which are already structured similarly to subscript expressions.
1 parent 44a4727 commit 760d4be

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

lib/Sema/CSGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2977,7 +2977,7 @@ namespace {
29772977
auto memberLocator = CS.getConstraintLocator(
29782978
locator, ConstraintLocator::PathElement::getKeyPathComponent(i));
29792979
auto resultLocator = CS.getConstraintLocator(
2980-
memberLocator, ConstraintLocator::FunctionResult);
2980+
memberLocator, ConstraintLocator::KeyPathComponentResult);
29812981

29822982
switch (auto kind = component.getKind()) {
29832983
case KeyPathExpr::Component::Kind::Invalid:

lib/Sema/ConstraintLocator.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ void ConstraintLocator::Profile(llvm::FoldingSetNodeID &id, Expr *anchor,
8181
case SynthesizedArgument:
8282
case KeyPathRoot:
8383
case KeyPathValue:
84+
case KeyPathComponentResult:
8485
if (unsigned numValues = numNumericValuesInPathElement(elt.getKind())) {
8586
id.AddInteger(elt.getValue());
8687
if (numValues > 1)
@@ -332,19 +333,23 @@ void ConstraintLocator::dump(SourceManager *sm, raw_ostream &out) {
332333
break;
333334

334335
case SynthesizedArgument:
335-
out << " synthesized argument #" << llvm::utostr(elt.getValue());
336+
out << "synthesized argument #" << llvm::utostr(elt.getValue());
336337
break;
337338

338339
case KeyPathDynamicMember:
339-
out << " keypath dynamic member lookup";
340+
out << "key path dynamic member lookup";
340341
break;
341342

342343
case KeyPathRoot:
343-
out << " keypath root";
344+
out << "key path root";
344345
break;
345346

346347
case KeyPathValue:
347-
out << " keypath value";
348+
out << "key path value";
349+
break;
350+
351+
case KeyPathComponentResult:
352+
out << "key path component result";
348353
break;
349354
}
350355
}

lib/Sema/ConstraintLocator.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ class ConstraintLocator : public llvm::FoldingSetNode {
133133
KeyPathRoot,
134134
/// The value of a keypath
135135
KeyPathValue,
136+
/// The result type of a key path component. Not used for subscripts.
137+
KeyPathComponentResult,
136138
};
137139

138140
/// Determine the number of numeric values used for the given path
@@ -165,6 +167,7 @@ class ConstraintLocator : public llvm::FoldingSetNode {
165167
case ContextualType:
166168
case KeyPathRoot:
167169
case KeyPathValue:
170+
case KeyPathComponentResult:
168171
return 0;
169172

170173
case OpenedGeneric:
@@ -233,6 +236,7 @@ class ConstraintLocator : public llvm::FoldingSetNode {
233236
case KeyPathDynamicMember:
234237
case KeyPathRoot:
235238
case KeyPathValue:
239+
case KeyPathComponentResult:
236240
return 0;
237241

238242
case FunctionArgument:

0 commit comments

Comments
 (0)