Skip to content

Commit 7e8aa9f

Browse files
committed
[NFC] Rename @lvalue Locator Path Element
8271c1a removed the last hacky usage of ArrayElementType, leaving behind just the @lvalue-to-inout conversions. Rename the locator path element to reflect this and do a bit of cleanup on the unrelated-but-near-enough other hack RValueAdjustment.
1 parent ec5b51e commit 7e8aa9f

File tree

6 files changed

+31
-29
lines changed

6 files changed

+31
-29
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,11 @@ void constraints::simplifyLocator(Expr *&anchor,
195195
break;
196196

197197
case ConstraintLocator::AutoclosureResult:
198-
case ConstraintLocator::RvalueAdjustment:
198+
case ConstraintLocator::LValueConversion:
199+
case ConstraintLocator::RValueAdjustment:
199200
case ConstraintLocator::ScalarToTuple:
200201
case ConstraintLocator::UnresolvedMember:
201-
// Arguments in autoclosure positions, rvalue adjustments, and
202+
// Arguments in autoclosure positions, lvalue and rvalue adjustments, and
202203
// scalar-to-tuple conversions, and unresolved members are
203204
// implicit.
204205
path = path.slice(1);

lib/Sema/CSGen.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,12 +1487,12 @@ namespace {
14871487
// If there is an argument, apply it.
14881488
if (auto arg = expr->getArgument()) {
14891489
// The result type of the function must be convertible to the base type.
1490-
// TODO: we definitely want this to include ImplicitlyUnwrappedOptional; does it
1491-
// need to include everything else in the world?
1490+
// TODO: we definitely want this to include ImplicitlyUnwrappedOptional;
1491+
// does it need to include everything else in the world?
14921492
auto outputTy = CS.createTypeVariable(
14931493
CS.getConstraintLocator(expr, ConstraintLocator::FunctionResult));
14941494
CS.addConstraint(ConstraintKind::Conversion, outputTy, baseTy,
1495-
CS.getConstraintLocator(expr, ConstraintLocator::RvalueAdjustment));
1495+
CS.getConstraintLocator(expr, ConstraintLocator::RValueAdjustment));
14961496

14971497
// The function/enum case must be callable with the given argument.
14981498
auto funcTy = FunctionType::get(CS.getType(arg), outputTy);
@@ -1505,7 +1505,7 @@ namespace {
15051505

15061506
// Otherwise, the member needs to be convertible to the base type.
15071507
CS.addConstraint(ConstraintKind::Conversion, memberTy, baseTy,
1508-
CS.getConstraintLocator(expr, ConstraintLocator::RvalueAdjustment));
1508+
CS.getConstraintLocator(expr, ConstraintLocator::RValueAdjustment));
15091509

15101510
// The member type also needs to be convertible to the context type, which
15111511
// preserves lvalue-ness.
@@ -2388,7 +2388,7 @@ namespace {
23882388
auto tv = CS.createTypeVariable(CS.getConstraintLocator(expr));
23892389
CS.addConstraint(ConstraintKind::DynamicTypeOf, tv,
23902390
CS.getType(expr->getBase()),
2391-
CS.getConstraintLocator(expr, ConstraintLocator::RvalueAdjustment));
2391+
CS.getConstraintLocator(expr, ConstraintLocator::RValueAdjustment));
23922392
return tv;
23932393
}
23942394

lib/Sema/CSSimplify.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,7 +1925,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
19251925
cast<LValueType>(desugar2)->getObjectType(),
19261926
ConstraintKind::Equal, subflags,
19271927
locator.withPathElement(
1928-
ConstraintLocator::ArrayElementType));
1928+
ConstraintLocator::LValueConversion));
19291929

19301930
case TypeKind::InOut:
19311931
// If the RHS is an inout type, the LHS must be an @lvalue type.
@@ -1936,7 +1936,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
19361936
return matchTypes(cast<InOutType>(desugar1)->getObjectType(),
19371937
cast<InOutType>(desugar2)->getObjectType(),
19381938
ConstraintKind::Equal, subflags,
1939-
locator.withPathElement(ConstraintLocator::ArrayElementType));
1939+
locator.withPathElement(ConstraintLocator::LValueConversion));
19401940

19411941
case TypeKind::UnboundGeneric:
19421942
llvm_unreachable("Unbound generic type should have been opened");
@@ -2303,7 +2303,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
23032303
return matchTypes(type1, LValueType::get(iot->getObjectType()),
23042304
kind, subflags,
23052305
locator.withPathElement(
2306-
ConstraintLocator::ArrayElementType));
2306+
ConstraintLocator::LValueConversion));
23072307
}
23082308
}
23092309

@@ -2337,7 +2337,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
23372337
return matchTypes(iot->getObjectType(), lvt->getObjectType(),
23382338
ConstraintKind::Bind, subflags,
23392339
locator.withPathElement(
2340-
ConstraintLocator::ArrayElementType));
2340+
ConstraintLocator::LValueConversion));
23412341
}
23422342
}
23432343
}

lib/Sema/ConstraintLocator.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ void ConstraintLocator::Profile(llvm::FoldingSetNodeID &id, Expr *anchor,
6161
case SubscriptMember:
6262
case SubscriptResult:
6363
case ConstructorMember:
64-
case RvalueAdjustment:
64+
case LValueConversion:
65+
case RValueAdjustment:
6566
case ClosureResult:
6667
case ParentType:
6768
case InstanceType:
6869
case SequenceIteratorProtocol:
6970
case GeneratorElementType:
70-
case ArrayElementType:
7171
case ScalarToTuple:
7272
case AutoclosureResult:
7373
case GenericArgument:
@@ -115,10 +115,6 @@ void ConstraintLocator::dump(SourceManager *sm, raw_ostream &out) {
115115
for (auto elt : getPath()) {
116116
out << " -> ";
117117
switch (elt.getKind()) {
118-
case ArrayElementType:
119-
out << "array element";
120-
break;
121-
122118
case Archetype:
123119
out << "archetype '" << elt.getArchetype()->getString() << "'";
124120
break;
@@ -197,7 +193,11 @@ void ConstraintLocator::dump(SourceManager *sm, raw_ostream &out) {
197193
out << "parent type";
198194
break;
199195

200-
case RvalueAdjustment:
196+
case LValueConversion:
197+
out << "@lvalue-to-inout conversion";
198+
break;
199+
200+
case RValueAdjustment:
201201
out << "rvalue adjustment";
202202
break;
203203

lib/Sema/ConstraintLocator.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,11 @@ class ConstraintLocator : public llvm::FoldingSetNode {
9595
SubscriptResult,
9696
/// \brief The lookup for a constructor member.
9797
ConstructorMember,
98-
/// \brief Rvalue adjustment.
99-
RvalueAdjustment,
98+
/// \brief An implicit @lvalue-to-inout conversion; only valid for operator
99+
/// arguments.
100+
LValueConversion,
101+
/// \brief RValue adjustment.
102+
RValueAdjustment,
100103
/// \brief The result of a closure.
101104
ClosureResult,
102105
/// \brief The parent of a nested type.
@@ -107,8 +110,6 @@ class ConstraintLocator : public llvm::FoldingSetNode {
107110
SequenceIteratorProtocol,
108111
/// \brief The element type of a generator.
109112
GeneratorElementType,
110-
/// \brief The element of an array type.
111-
ArrayElementType,
112113
/// \brief The scalar type of a tuple type.
113114
ScalarToTuple,
114115
/// \brief An argument passed in an autoclosure parameter
@@ -152,13 +153,13 @@ class ConstraintLocator : public llvm::FoldingSetNode {
152153
case SubscriptMember:
153154
case SubscriptResult:
154155
case ConstructorMember:
155-
case RvalueAdjustment:
156+
case LValueConversion:
157+
case RValueAdjustment:
156158
case ClosureResult:
157159
case ParentType:
158160
case InstanceType:
159161
case SequenceIteratorProtocol:
160162
case GeneratorElementType:
161-
case ArrayElementType:
162163
case ScalarToTuple:
163164
case AutoclosureResult:
164165
case Requirement:
@@ -202,7 +203,6 @@ class ConstraintLocator : public llvm::FoldingSetNode {
202203
case ApplyArgToParam:
203204
case SequenceIteratorProtocol:
204205
case GeneratorElementType:
205-
case ArrayElementType:
206206
case ClosureResult:
207207
case ConstructorMember:
208208
case InstanceType:
@@ -212,7 +212,8 @@ class ConstraintLocator : public llvm::FoldingSetNode {
212212
case MemberRefBase:
213213
case UnresolvedMember:
214214
case ParentType:
215-
case RvalueAdjustment:
215+
case LValueConversion:
216+
case RValueAdjustment:
216217
case ScalarToTuple:
217218
case SubscriptIndex:
218219
case SubscriptMember:

lib/Sema/ConstraintSystem.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,7 @@ resolveOverloadForDeclWithSpecialTypeCheckingSemantics(ConstraintSystem &CS,
15711571
auto inputTuple = TupleType::get(inputArg, CS.getASTContext());
15721572

15731573
CS.addConstraint(ConstraintKind::DynamicTypeOf, output, input,
1574-
CS.getConstraintLocator(locator, ConstraintLocator::RvalueAdjustment));
1574+
CS.getConstraintLocator(locator, ConstraintLocator::RValueAdjustment));
15751575
refType = FunctionType::get(inputTuple, output);
15761576
openedFullType = refType;
15771577
return true;
@@ -1586,7 +1586,7 @@ resolveOverloadForDeclWithSpecialTypeCheckingSemantics(ConstraintSystem &CS,
15861586
CS.getConstraintLocator(locator, ConstraintLocator::FunctionArgument));
15871587
CS.addConstraint(ConstraintKind::EscapableFunctionOf,
15881588
escapeClosure, noescapeClosure,
1589-
CS.getConstraintLocator(locator, ConstraintLocator::RvalueAdjustment));
1589+
CS.getConstraintLocator(locator, ConstraintLocator::RValueAdjustment));
15901590
auto result = CS.createTypeVariable(
15911591
CS.getConstraintLocator(locator, ConstraintLocator::FunctionResult));
15921592
auto bodyClosure = FunctionType::get(
@@ -1618,7 +1618,7 @@ resolveOverloadForDeclWithSpecialTypeCheckingSemantics(ConstraintSystem &CS,
16181618
CS.getConstraintLocator(locator, ConstraintLocator::FunctionArgument));
16191619
CS.addConstraint(ConstraintKind::OpenedExistentialOf,
16201620
openedTy, existentialTy,
1621-
CS.getConstraintLocator(locator, ConstraintLocator::RvalueAdjustment));
1621+
CS.getConstraintLocator(locator, ConstraintLocator::RValueAdjustment));
16221622
auto result = CS.createTypeVariable(
16231623
CS.getConstraintLocator(locator, ConstraintLocator::FunctionResult));
16241624
auto bodyClosure = FunctionType::get(

0 commit comments

Comments
 (0)