Skip to content

Commit 3a01f20

Browse files
committed
Sema: Rename LocatorPathElt::OptionalPayload to ::OptionalInjection
1 parent d56d704 commit 3a01f20

File tree

7 files changed

+24
-24
lines changed

7 files changed

+24
-24
lines changed

include/swift/Sema/ConstraintLocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ class ConstraintLocatorBuilder {
12751275

12761276
auto last = std::find_if(
12771277
path.rbegin(), path.rend(), [](LocatorPathElt &elt) -> bool {
1278-
return elt.getKind() != ConstraintLocator::OptionalPayload &&
1278+
return elt.getKind() != ConstraintLocator::OptionalInjection &&
12791279
elt.getKind() != ConstraintLocator::GenericArgument;
12801280
});
12811281

include/swift/Sema/ConstraintLocatorPathElts.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ CUSTOM_LOCATOR_PATH_ELT(OpenedGeneric)
153153
/// type at the base of the locator.
154154
CUSTOM_LOCATOR_PATH_ELT(OpenedOpaqueArchetype)
155155

156-
/// An optional payload.
157-
SIMPLE_LOCATOR_PATH_ELT(OptionalPayload)
156+
/// The optional payload in an optional injection, ie a T -> T? conversion.
157+
SIMPLE_LOCATOR_PATH_ELT(OptionalInjection)
158158

159159
/// The parent of a nested type.
160160
SIMPLE_LOCATOR_PATH_ELT(ParentType)

lib/Sema/CSDiagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ bool GenericArgumentsMismatchFailure::diagnoseAsError() {
940940

941941
while (!path.empty()) {
942942
auto last = path.back();
943-
if (last.is<LocatorPathElt::OptionalPayload>() ||
943+
if (last.is<LocatorPathElt::OptionalInjection>() ||
944944
last.is<LocatorPathElt::GenericType>() ||
945945
last.is<LocatorPathElt::GenericArgument>()) {
946946
path = path.drop_back();

lib/Sema/CSGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4672,7 +4672,7 @@ generateForEachStmtConstraints(ConstraintSystem &cs, DeclContext *dc,
46724672
// Add a conversion constraint between the element type of the sequence
46734673
// and the type of the element pattern.
46744674
auto *elementTypeLoc = cs.getConstraintLocator(
4675-
elementLocator, ConstraintLocator::OptionalPayload);
4675+
elementLocator, ConstraintLocator::OptionalInjection);
46764676
auto elementType = cs.createTypeVariable(elementTypeLoc,
46774677
/*flags=*/0);
46784678
{

lib/Sema/CSSimplify.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3323,11 +3323,11 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
33233323
SmallVector<LocatorPathElt, 4> path;
33243324
locator.getLocatorParts(path);
33253325

3326-
// Find the last path element, skipping OptionalPayload elements
3326+
// Find the last path element, skipping OptionalInjection elements
33273327
// so that we allow this exception in cases of optional injection.
33283328
auto last = std::find_if(
33293329
path.rbegin(), path.rend(), [](LocatorPathElt &elt) -> bool {
3330-
return elt.getKind() != ConstraintLocator::OptionalPayload;
3330+
return elt.getKind() != ConstraintLocator::OptionalInjection;
33313331
});
33323332

33333333
auto &ctx = getASTContext();
@@ -3431,12 +3431,12 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
34313431

34323432
// Find the last path element, skipping GenericArgument elements
34333433
// so that we allow this exception in cases of optional types, and
3434-
// skipping OptionalPayload elements so that we allow this
3434+
// skipping OptionalInjection elements so that we allow this
34353435
// exception in cases of optional injection.
34363436
auto last = std::find_if(
34373437
path.rbegin(), path.rend(), [](LocatorPathElt &elt) -> bool {
34383438
return elt.getKind() != ConstraintLocator::GenericArgument &&
3439-
elt.getKind() != ConstraintLocator::OptionalPayload;
3439+
elt.getKind() != ConstraintLocator::OptionalInjection;
34403440
});
34413441

34423442
if (last != path.rend()) {
@@ -3484,7 +3484,7 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
34843484
//
34853485
// func foo(_: ((Int, Int) -> Void)?) {}
34863486
// _ = foo { _ in } <- missing second closure parameter.
3487-
if (loc->isLastElement<LocatorPathElt::OptionalPayload>()) {
3487+
if (loc->isLastElement<LocatorPathElt::OptionalInjection>()) {
34883488
auto path = loc->getPath();
34893489
loc = getConstraintLocator(loc->getAnchor(), path.drop_back());
34903490
}
@@ -4144,7 +4144,7 @@ ConstraintSystem::matchExistentialTypes(Type type1, Type type2,
41444144
// `value-to-optional` or `optional-to-optional` conversion
41454145
// associated with them (expected argument is `AnyObject?`).
41464146
if (!path.empty() &&
4147-
(path.back().is<LocatorPathElt::OptionalPayload>() ||
4147+
(path.back().is<LocatorPathElt::OptionalInjection>() ||
41484148
path.back().is<LocatorPathElt::GenericArgument>()))
41494149
path.pop_back();
41504150

@@ -4200,7 +4200,7 @@ ConstraintSystem::matchExistentialTypes(Type type1, Type type2,
42004200
// If the path ends at `optional payload` it means that this
42014201
// check is part of an implicit value-to-optional conversion,
42024202
// and it could be safely dropped.
4203-
if (!path.empty() && path.back().is<LocatorPathElt::OptionalPayload>())
4203+
if (!path.empty() && path.back().is<LocatorPathElt::OptionalInjection>())
42044204
path.pop_back();
42054205

42064206
// Determine whether this conformance mismatch is
@@ -6495,7 +6495,7 @@ bool ConstraintSystem::repairFailures(
64956495
// If the mismatch is a part of either optional-to-optional or
64966496
// value-to-optional conversions, let's allow fix refer to a complete
64976497
// top level type and not just a part of it.
6498-
if (tupleLocator->findLast<LocatorPathElt::OptionalPayload>())
6498+
if (tupleLocator->findLast<LocatorPathElt::OptionalInjection>())
64996499
break;
65006500

65016501
if (tupleLocator->isForContextualType()) {
@@ -6636,7 +6636,7 @@ bool ConstraintSystem::repairFailures(
66366636
break;
66376637
}
66386638

6639-
case ConstraintLocator::OptionalPayload: {
6639+
case ConstraintLocator::OptionalInjection: {
66406640
if (lhs->isPlaceholder() || rhs->isPlaceholder())
66416641
return true;
66426642

@@ -7446,7 +7446,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
74467446
// Look through all value-to-optional promotions to allow
74477447
// conversions like Double -> CGFloat?? and vice versa.
74487448
// T -> Optional<T>
7449-
if (location.endsWith<LocatorPathElt::OptionalPayload>() ||
7449+
if (location.endsWith<LocatorPathElt::OptionalInjection>() ||
74507450
location.endsWith<LocatorPathElt::GenericArgument>()) {
74517451
SmallVector<LocatorPathElt, 4> path;
74527452
auto anchor = location.getLocatorParts(path);
@@ -7456,7 +7456,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
74567456
path.erase(llvm::remove_if(
74577457
path,
74587458
[](const LocatorPathElt &elt) {
7459-
return elt.is<LocatorPathElt::OptionalPayload>() ||
7459+
return elt.is<LocatorPathElt::OptionalInjection>() ||
74607460
elt.is<LocatorPathElt::GenericArgument>();
74617461
}),
74627462
path.end());
@@ -14608,7 +14608,7 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
1460814608
if (generic2->getDecl()->isOptionalDecl()) {
1460914609
auto result = matchTypes(
1461014610
type1, generic2->getGenericArgs()[0], matchKind, subflags,
14611-
locator.withPathElement(ConstraintLocator::OptionalPayload));
14611+
locator.withPathElement(ConstraintLocator::OptionalInjection));
1461214612

1461314613
if (!(shouldAttemptFixes() && result.isFailure()))
1461414614
return result;

lib/Sema/ConstraintLocator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ unsigned LocatorPathElt::getNewSummaryFlags() const {
5252
case ConstraintLocator::ResultBuilderBodyResult:
5353
case ConstraintLocator::InstanceType:
5454
case ConstraintLocator::AutoclosureResult:
55-
case ConstraintLocator::OptionalPayload:
55+
case ConstraintLocator::OptionalInjection:
5656
case ConstraintLocator::Member:
5757
case ConstraintLocator::MemberRefBase:
5858
case ConstraintLocator::UnresolvedMember:
@@ -176,8 +176,8 @@ void LocatorPathElt::dump(raw_ostream &out) const {
176176
out << "apply function";
177177
break;
178178

179-
case ConstraintLocator::OptionalPayload:
180-
out << "optional payload";
179+
case ConstraintLocator::OptionalInjection:
180+
out << "optional injection";
181181
break;
182182

183183
case ConstraintLocator::ApplyArgToParam: {

lib/Sema/ConstraintSystem.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ ConstraintLocator *ConstraintSystem::getImplicitValueConversionLocator(
644644
// Drop any value-to-optional conversions that were applied along the
645645
// way to reach this one.
646646
while (!path.empty()) {
647-
if (path.back().is<LocatorPathElt::OptionalPayload>()) {
647+
if (path.back().is<LocatorPathElt::OptionalInjection>()) {
648648
path.pop_back();
649649
continue;
650650
}
@@ -3772,7 +3772,7 @@ void constraints::simplifyLocator(ASTNode &anchor,
37723772

37733773
case ConstraintLocator::Witness:
37743774
case ConstraintLocator::WrappedValue:
3775-
case ConstraintLocator::OptionalPayload:
3775+
case ConstraintLocator::OptionalInjection:
37763776
case ConstraintLocator::ImplicitlyUnwrappedDisjunctionChoice:
37773777
case ConstraintLocator::FallbackType:
37783778
case ConstraintLocator::KeyPathSubscriptIndex:
@@ -4068,7 +4068,7 @@ Solution::getFunctionArgApplyInfo(ConstraintLocator *locator) const {
40684068
// Look for the apply-arg-to-param element in the locator's path. We may
40694069
// have to look through other elements that are generated from an argument
40704070
// conversion such as GenericArgument for an optional-to-optional conversion,
4071-
// and OptionalPayload for a value-to-optional conversion.
4071+
// and OptionalInjection for a value-to-optional conversion.
40724072
auto iter = path.rbegin();
40734073
auto applyArgElt = locator->findLast<LocatorPathElt::ApplyArgToParam>(iter);
40744074
if (!applyArgElt)
@@ -4343,7 +4343,7 @@ bool ConstraintSystem::isArgumentOfImportedDecl(
43434343
// locator elements at the end of the path, they came from
43444344
// either value-to-optional promotion or optional-to-optional
43454345
// conversion.
4346-
if (last.is<LocatorPathElt::OptionalPayload>() ||
4346+
if (last.is<LocatorPathElt::OptionalInjection>() ||
43474347
last.is<LocatorPathElt::GenericArgument>()) {
43484348
path.pop_back();
43494349
continue;

0 commit comments

Comments
 (0)