Skip to content

[ConstraintSystem] Remove RValueAdjustment locator element #34432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/swift/Sema/ConstraintLocatorPathElts.def
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ ABSTRACT_LOCATOR_PATH_ELT(AnyRequirement)
/// A single requirement placed on the type parameters.
CUSTOM_LOCATOR_PATH_ELT(TypeParameterRequirement)

/// RValue adjustment.
SIMPLE_LOCATOR_PATH_ELT(RValueAdjustment)
/// Access to `.dynamicType` element
SIMPLE_LOCATOR_PATH_ELT(DynamicType)

/// The element type of a sequence in a for ... in ... loop.
SIMPLE_LOCATOR_PATH_ELT(SequenceElementType)
Expand Down
8 changes: 4 additions & 4 deletions lib/Sema/BuilderTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,10 +810,10 @@ class BuilderClosureVisitor
VarDecl *arrayVar = buildVar(loc);
Type arrayElementType = cs->createTypeVariable(
cs->getConstraintLocator(forEachStmt), 0);
cs->addConstraint(
ConstraintKind::Equal, cs->getType(bodyVar), arrayElementType,
cs->getConstraintLocator(
forEachStmt, ConstraintLocator::RValueAdjustment));
cs->addConstraint(ConstraintKind::Equal, cs->getType(bodyVar),
arrayElementType,
cs->getConstraintLocator(
forEachStmt, ConstraintLocator::SequenceElementType));
Type arrayType = ArraySliceType::get(arrayElementType);
cs->setType(arrayVar, arrayType);

Expand Down
3 changes: 0 additions & 3 deletions lib/Sema/CSDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2463,9 +2463,6 @@ void ContextualFailure::tryFixIts(InFlightDiagnostic &diagnostic) const {
}

bool ContextualFailure::diagnoseMissingFunctionCall() const {
if (getLocator()->isLastElement<LocatorPathElt::RValueAdjustment>())
return false;

if (getLocator()
->isLastElement<LocatorPathElt::UnresolvedMemberChainResult>())
return false;
Expand Down
9 changes: 3 additions & 6 deletions lib/Sema/CSGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1446,9 +1446,6 @@ namespace {

// The result of the last element of the chain must be convertible to the
// whole chain, and the type of the whole chain must be equal to the base.
CS.addConstraint(
ConstraintKind::Conversion, memberTy, chainBaseTy,
CS.getConstraintLocator(tail, ConstraintLocator::RValueAdjustment));
CS.addConstraint(ConstraintKind::Conversion, memberTy, chainResultTy,
locator);
CS.addConstraint(ConstraintKind::Equal, chainBaseTy, chainResultTy,
Expand Down Expand Up @@ -2594,9 +2591,9 @@ namespace {
Type visitDynamicTypeExpr(DynamicTypeExpr *expr) {
auto tv = CS.createTypeVariable(CS.getConstraintLocator(expr),
TVO_CanBindToNoEscape);
CS.addConstraint(ConstraintKind::DynamicTypeOf, tv,
CS.getType(expr->getBase()),
CS.getConstraintLocator(expr, ConstraintLocator::RValueAdjustment));
CS.addConstraint(
ConstraintKind::DynamicTypeOf, tv, CS.getType(expr->getBase()),
CS.getConstraintLocator(expr, ConstraintLocator::DynamicType));
return tv;
}

Expand Down
3 changes: 0 additions & 3 deletions lib/Sema/CSSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4371,9 +4371,6 @@ bool ConstraintSystem::repairFailures(
break;
}

case ConstraintLocator::RValueAdjustment:
return true;

case ConstraintLocator::UnresolvedMemberChainResult: {
if (repairViaOptionalUnwrap(*this, lhs, rhs, matchKind, conversionsOrFixes,
locator))
Expand Down
6 changes: 3 additions & 3 deletions lib/Sema/ConstraintLocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ unsigned LocatorPathElt::getNewSummaryFlags() const {
case ConstraintLocator::ParentType:
case ConstraintLocator::ExistentialSuperclassType:
case ConstraintLocator::LValueConversion:
case ConstraintLocator::RValueAdjustment:
case ConstraintLocator::DynamicType:
case ConstraintLocator::SubscriptMember:
case ConstraintLocator::OpenedGeneric:
case ConstraintLocator::GenericParameter:
Expand Down Expand Up @@ -350,8 +350,8 @@ void ConstraintLocator::dump(SourceManager *sm, raw_ostream &out) const {
out << "@lvalue-to-inout conversion";
break;

case RValueAdjustment:
out << "rvalue adjustment";
case DynamicType:
out << "`.dynamicType` reference";
break;

case SubscriptMember:
Expand Down
17 changes: 8 additions & 9 deletions lib/Sema/ConstraintSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1868,8 +1868,9 @@ static std::pair<Type, Type> getTypeOfReferenceWithSpecialTypeCheckingSemantics(
FunctionType::Param inputArg(input,
CS.getASTContext().getIdentifier("of"));

CS.addConstraint(ConstraintKind::DynamicTypeOf, output, input,
CS.getConstraintLocator(locator, ConstraintLocator::RValueAdjustment));
CS.addConstraint(
ConstraintKind::DynamicTypeOf, output, input,
CS.getConstraintLocator(locator, ConstraintLocator::DynamicType));
auto refType = FunctionType::get({inputArg}, output);
return {refType, refType};
}
Expand All @@ -1883,9 +1884,8 @@ static std::pair<Type, Type> getTypeOfReferenceWithSpecialTypeCheckingSemantics(
auto escapeClosure = CS.createTypeVariable(
CS.getConstraintLocator(locator, ConstraintLocator::FunctionArgument),
TVO_CanBindToNoEscape);
CS.addConstraint(ConstraintKind::EscapableFunctionOf,
escapeClosure, noescapeClosure,
CS.getConstraintLocator(locator, ConstraintLocator::RValueAdjustment));
CS.addConstraint(ConstraintKind::EscapableFunctionOf, escapeClosure,
noescapeClosure, CS.getConstraintLocator(locator));
auto result = CS.createTypeVariable(
CS.getConstraintLocator(locator, ConstraintLocator::FunctionResult),
TVO_CanBindToNoEscape);
Expand Down Expand Up @@ -1916,9 +1916,8 @@ static std::pair<Type, Type> getTypeOfReferenceWithSpecialTypeCheckingSemantics(
auto existentialTy = CS.createTypeVariable(
CS.getConstraintLocator(locator, ConstraintLocator::FunctionArgument),
TVO_CanBindToNoEscape);
CS.addConstraint(ConstraintKind::OpenedExistentialOf,
openedTy, existentialTy,
CS.getConstraintLocator(locator, ConstraintLocator::RValueAdjustment));
CS.addConstraint(ConstraintKind::OpenedExistentialOf, openedTy,
existentialTy, CS.getConstraintLocator(locator));
auto result = CS.createTypeVariable(
CS.getConstraintLocator(locator, ConstraintLocator::FunctionResult),
TVO_CanBindToNoEscape);
Expand Down Expand Up @@ -3914,7 +3913,7 @@ void constraints::simplifyLocator(ASTNode &anchor,

case ConstraintLocator::AutoclosureResult:
case ConstraintLocator::LValueConversion:
case ConstraintLocator::RValueAdjustment:
case ConstraintLocator::DynamicType:
case ConstraintLocator::UnresolvedMember:
case ConstraintLocator::ImplicitCallAsFunction:
// Arguments in autoclosure positions, lvalue and rvalue adjustments,
Expand Down