Skip to content

Commit 92fe04f

Browse files
authored
Merge pull request #34432 from xedin/remove-rvalue-adjument
[ConstraintSystem] Remove `RValueAdjustment` locator element
2 parents 84e5fd2 + 1683fb9 commit 92fe04f

File tree

7 files changed

+20
-30
lines changed

7 files changed

+20
-30
lines changed

include/swift/Sema/ConstraintLocatorPathElts.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ ABSTRACT_LOCATOR_PATH_ELT(AnyRequirement)
147147
/// A single requirement placed on the type parameters.
148148
CUSTOM_LOCATOR_PATH_ELT(TypeParameterRequirement)
149149

150-
/// RValue adjustment.
151-
SIMPLE_LOCATOR_PATH_ELT(RValueAdjustment)
150+
/// Access to `.dynamicType` element
151+
SIMPLE_LOCATOR_PATH_ELT(DynamicType)
152152

153153
/// The element type of a sequence in a for ... in ... loop.
154154
SIMPLE_LOCATOR_PATH_ELT(SequenceElementType)

lib/Sema/BuilderTransform.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -810,10 +810,10 @@ class BuilderClosureVisitor
810810
VarDecl *arrayVar = buildVar(loc);
811811
Type arrayElementType = cs->createTypeVariable(
812812
cs->getConstraintLocator(forEachStmt), 0);
813-
cs->addConstraint(
814-
ConstraintKind::Equal, cs->getType(bodyVar), arrayElementType,
815-
cs->getConstraintLocator(
816-
forEachStmt, ConstraintLocator::RValueAdjustment));
813+
cs->addConstraint(ConstraintKind::Equal, cs->getType(bodyVar),
814+
arrayElementType,
815+
cs->getConstraintLocator(
816+
forEachStmt, ConstraintLocator::SequenceElementType));
817817
Type arrayType = ArraySliceType::get(arrayElementType);
818818
cs->setType(arrayVar, arrayType);
819819

lib/Sema/CSDiagnostics.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,9 +2463,6 @@ void ContextualFailure::tryFixIts(InFlightDiagnostic &diagnostic) const {
24632463
}
24642464

24652465
bool ContextualFailure::diagnoseMissingFunctionCall() const {
2466-
if (getLocator()->isLastElement<LocatorPathElt::RValueAdjustment>())
2467-
return false;
2468-
24692466
if (getLocator()
24702467
->isLastElement<LocatorPathElt::UnresolvedMemberChainResult>())
24712468
return false;

lib/Sema/CSGen.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,9 +1446,6 @@ namespace {
14461446

14471447
// The result of the last element of the chain must be convertible to the
14481448
// whole chain, and the type of the whole chain must be equal to the base.
1449-
CS.addConstraint(
1450-
ConstraintKind::Conversion, memberTy, chainBaseTy,
1451-
CS.getConstraintLocator(tail, ConstraintLocator::RValueAdjustment));
14521449
CS.addConstraint(ConstraintKind::Conversion, memberTy, chainResultTy,
14531450
locator);
14541451
CS.addConstraint(ConstraintKind::Equal, chainBaseTy, chainResultTy,
@@ -2594,9 +2591,9 @@ namespace {
25942591
Type visitDynamicTypeExpr(DynamicTypeExpr *expr) {
25952592
auto tv = CS.createTypeVariable(CS.getConstraintLocator(expr),
25962593
TVO_CanBindToNoEscape);
2597-
CS.addConstraint(ConstraintKind::DynamicTypeOf, tv,
2598-
CS.getType(expr->getBase()),
2599-
CS.getConstraintLocator(expr, ConstraintLocator::RValueAdjustment));
2594+
CS.addConstraint(
2595+
ConstraintKind::DynamicTypeOf, tv, CS.getType(expr->getBase()),
2596+
CS.getConstraintLocator(expr, ConstraintLocator::DynamicType));
26002597
return tv;
26012598
}
26022599

lib/Sema/CSSimplify.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4371,9 +4371,6 @@ bool ConstraintSystem::repairFailures(
43714371
break;
43724372
}
43734373

4374-
case ConstraintLocator::RValueAdjustment:
4375-
return true;
4376-
43774374
case ConstraintLocator::UnresolvedMemberChainResult: {
43784375
if (repairViaOptionalUnwrap(*this, lhs, rhs, matchKind, conversionsOrFixes,
43794376
locator))

lib/Sema/ConstraintLocator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ unsigned LocatorPathElt::getNewSummaryFlags() const {
5454
case ConstraintLocator::ParentType:
5555
case ConstraintLocator::ExistentialSuperclassType:
5656
case ConstraintLocator::LValueConversion:
57-
case ConstraintLocator::RValueAdjustment:
57+
case ConstraintLocator::DynamicType:
5858
case ConstraintLocator::SubscriptMember:
5959
case ConstraintLocator::OpenedGeneric:
6060
case ConstraintLocator::GenericParameter:
@@ -350,8 +350,8 @@ void ConstraintLocator::dump(SourceManager *sm, raw_ostream &out) const {
350350
out << "@lvalue-to-inout conversion";
351351
break;
352352

353-
case RValueAdjustment:
354-
out << "rvalue adjustment";
353+
case DynamicType:
354+
out << "`.dynamicType` reference";
355355
break;
356356

357357
case SubscriptMember:

lib/Sema/ConstraintSystem.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,8 +1868,9 @@ static std::pair<Type, Type> getTypeOfReferenceWithSpecialTypeCheckingSemantics(
18681868
FunctionType::Param inputArg(input,
18691869
CS.getASTContext().getIdentifier("of"));
18701870

1871-
CS.addConstraint(ConstraintKind::DynamicTypeOf, output, input,
1872-
CS.getConstraintLocator(locator, ConstraintLocator::RValueAdjustment));
1871+
CS.addConstraint(
1872+
ConstraintKind::DynamicTypeOf, output, input,
1873+
CS.getConstraintLocator(locator, ConstraintLocator::DynamicType));
18731874
auto refType = FunctionType::get({inputArg}, output);
18741875
return {refType, refType};
18751876
}
@@ -1883,9 +1884,8 @@ static std::pair<Type, Type> getTypeOfReferenceWithSpecialTypeCheckingSemantics(
18831884
auto escapeClosure = CS.createTypeVariable(
18841885
CS.getConstraintLocator(locator, ConstraintLocator::FunctionArgument),
18851886
TVO_CanBindToNoEscape);
1886-
CS.addConstraint(ConstraintKind::EscapableFunctionOf,
1887-
escapeClosure, noescapeClosure,
1888-
CS.getConstraintLocator(locator, ConstraintLocator::RValueAdjustment));
1887+
CS.addConstraint(ConstraintKind::EscapableFunctionOf, escapeClosure,
1888+
noescapeClosure, CS.getConstraintLocator(locator));
18891889
auto result = CS.createTypeVariable(
18901890
CS.getConstraintLocator(locator, ConstraintLocator::FunctionResult),
18911891
TVO_CanBindToNoEscape);
@@ -1916,9 +1916,8 @@ static std::pair<Type, Type> getTypeOfReferenceWithSpecialTypeCheckingSemantics(
19161916
auto existentialTy = CS.createTypeVariable(
19171917
CS.getConstraintLocator(locator, ConstraintLocator::FunctionArgument),
19181918
TVO_CanBindToNoEscape);
1919-
CS.addConstraint(ConstraintKind::OpenedExistentialOf,
1920-
openedTy, existentialTy,
1921-
CS.getConstraintLocator(locator, ConstraintLocator::RValueAdjustment));
1919+
CS.addConstraint(ConstraintKind::OpenedExistentialOf, openedTy,
1920+
existentialTy, CS.getConstraintLocator(locator));
19221921
auto result = CS.createTypeVariable(
19231922
CS.getConstraintLocator(locator, ConstraintLocator::FunctionResult),
19241923
TVO_CanBindToNoEscape);
@@ -3914,7 +3913,7 @@ void constraints::simplifyLocator(ASTNode &anchor,
39143913

39153914
case ConstraintLocator::AutoclosureResult:
39163915
case ConstraintLocator::LValueConversion:
3917-
case ConstraintLocator::RValueAdjustment:
3916+
case ConstraintLocator::DynamicType:
39183917
case ConstraintLocator::UnresolvedMember:
39193918
case ConstraintLocator::ImplicitCallAsFunction:
39203919
// Arguments in autoclosure positions, lvalue and rvalue adjustments,

0 commit comments

Comments
 (0)