[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.
This commit is contained in:
Robert Widmann
2018-05-26 16:42:46 -07:00
parent ec5b51ec7c
commit 7e8aa9fcc6
6 changed files with 31 additions and 29 deletions

View File

@@ -195,10 +195,11 @@ void constraints::simplifyLocator(Expr *&anchor,
break;
case ConstraintLocator::AutoclosureResult:
case ConstraintLocator::RvalueAdjustment:
case ConstraintLocator::LValueConversion:
case ConstraintLocator::RValueAdjustment:
case ConstraintLocator::ScalarToTuple:
case ConstraintLocator::UnresolvedMember:
// Arguments in autoclosure positions, rvalue adjustments, and
// Arguments in autoclosure positions, lvalue and rvalue adjustments, and
// scalar-to-tuple conversions, and unresolved members are
// implicit.
path = path.slice(1);

View File

@@ -1487,12 +1487,12 @@ namespace {
// If there is an argument, apply it.
if (auto arg = expr->getArgument()) {
// The result type of the function must be convertible to the base type.
// TODO: we definitely want this to include ImplicitlyUnwrappedOptional; does it
// need to include everything else in the world?
// TODO: we definitely want this to include ImplicitlyUnwrappedOptional;
// does it need to include everything else in the world?
auto outputTy = CS.createTypeVariable(
CS.getConstraintLocator(expr, ConstraintLocator::FunctionResult));
CS.addConstraint(ConstraintKind::Conversion, outputTy, baseTy,
CS.getConstraintLocator(expr, ConstraintLocator::RvalueAdjustment));
CS.getConstraintLocator(expr, ConstraintLocator::RValueAdjustment));
// The function/enum case must be callable with the given argument.
auto funcTy = FunctionType::get(CS.getType(arg), outputTy);
@@ -1505,7 +1505,7 @@ namespace {
// Otherwise, the member needs to be convertible to the base type.
CS.addConstraint(ConstraintKind::Conversion, memberTy, baseTy,
CS.getConstraintLocator(expr, ConstraintLocator::RvalueAdjustment));
CS.getConstraintLocator(expr, ConstraintLocator::RValueAdjustment));
// The member type also needs to be convertible to the context type, which
// preserves lvalue-ness.
@@ -2388,7 +2388,7 @@ namespace {
auto tv = CS.createTypeVariable(CS.getConstraintLocator(expr));
CS.addConstraint(ConstraintKind::DynamicTypeOf, tv,
CS.getType(expr->getBase()),
CS.getConstraintLocator(expr, ConstraintLocator::RvalueAdjustment));
CS.getConstraintLocator(expr, ConstraintLocator::RValueAdjustment));
return tv;
}

View File

@@ -1925,7 +1925,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
cast<LValueType>(desugar2)->getObjectType(),
ConstraintKind::Equal, subflags,
locator.withPathElement(
ConstraintLocator::ArrayElementType));
ConstraintLocator::LValueConversion));
case TypeKind::InOut:
// 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,
return matchTypes(cast<InOutType>(desugar1)->getObjectType(),
cast<InOutType>(desugar2)->getObjectType(),
ConstraintKind::Equal, subflags,
locator.withPathElement(ConstraintLocator::ArrayElementType));
locator.withPathElement(ConstraintLocator::LValueConversion));
case TypeKind::UnboundGeneric:
llvm_unreachable("Unbound generic type should have been opened");
@@ -2303,7 +2303,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
return matchTypes(type1, LValueType::get(iot->getObjectType()),
kind, subflags,
locator.withPathElement(
ConstraintLocator::ArrayElementType));
ConstraintLocator::LValueConversion));
}
}
@@ -2337,7 +2337,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
return matchTypes(iot->getObjectType(), lvt->getObjectType(),
ConstraintKind::Bind, subflags,
locator.withPathElement(
ConstraintLocator::ArrayElementType));
ConstraintLocator::LValueConversion));
}
}
}

View File

@@ -61,13 +61,13 @@ void ConstraintLocator::Profile(llvm::FoldingSetNodeID &id, Expr *anchor,
case SubscriptMember:
case SubscriptResult:
case ConstructorMember:
case RvalueAdjustment:
case LValueConversion:
case RValueAdjustment:
case ClosureResult:
case ParentType:
case InstanceType:
case SequenceIteratorProtocol:
case GeneratorElementType:
case ArrayElementType:
case ScalarToTuple:
case AutoclosureResult:
case GenericArgument:
@@ -115,10 +115,6 @@ void ConstraintLocator::dump(SourceManager *sm, raw_ostream &out) {
for (auto elt : getPath()) {
out << " -> ";
switch (elt.getKind()) {
case ArrayElementType:
out << "array element";
break;
case Archetype:
out << "archetype '" << elt.getArchetype()->getString() << "'";
break;
@@ -197,7 +193,11 @@ void ConstraintLocator::dump(SourceManager *sm, raw_ostream &out) {
out << "parent type";
break;
case RvalueAdjustment:
case LValueConversion:
out << "@lvalue-to-inout conversion";
break;
case RValueAdjustment:
out << "rvalue adjustment";
break;

View File

@@ -95,8 +95,11 @@ public:
SubscriptResult,
/// \brief The lookup for a constructor member.
ConstructorMember,
/// \brief Rvalue adjustment.
RvalueAdjustment,
/// \brief An implicit @lvalue-to-inout conversion; only valid for operator
/// arguments.
LValueConversion,
/// \brief RValue adjustment.
RValueAdjustment,
/// \brief The result of a closure.
ClosureResult,
/// \brief The parent of a nested type.
@@ -107,8 +110,6 @@ public:
SequenceIteratorProtocol,
/// \brief The element type of a generator.
GeneratorElementType,
/// \brief The element of an array type.
ArrayElementType,
/// \brief The scalar type of a tuple type.
ScalarToTuple,
/// \brief An argument passed in an autoclosure parameter
@@ -152,13 +153,13 @@ public:
case SubscriptMember:
case SubscriptResult:
case ConstructorMember:
case RvalueAdjustment:
case LValueConversion:
case RValueAdjustment:
case ClosureResult:
case ParentType:
case InstanceType:
case SequenceIteratorProtocol:
case GeneratorElementType:
case ArrayElementType:
case ScalarToTuple:
case AutoclosureResult:
case Requirement:
@@ -202,7 +203,6 @@ public:
case ApplyArgToParam:
case SequenceIteratorProtocol:
case GeneratorElementType:
case ArrayElementType:
case ClosureResult:
case ConstructorMember:
case InstanceType:
@@ -212,7 +212,8 @@ public:
case MemberRefBase:
case UnresolvedMember:
case ParentType:
case RvalueAdjustment:
case LValueConversion:
case RValueAdjustment:
case ScalarToTuple:
case SubscriptIndex:
case SubscriptMember:

View File

@@ -1571,7 +1571,7 @@ resolveOverloadForDeclWithSpecialTypeCheckingSemantics(ConstraintSystem &CS,
auto inputTuple = TupleType::get(inputArg, CS.getASTContext());
CS.addConstraint(ConstraintKind::DynamicTypeOf, output, input,
CS.getConstraintLocator(locator, ConstraintLocator::RvalueAdjustment));
CS.getConstraintLocator(locator, ConstraintLocator::RValueAdjustment));
refType = FunctionType::get(inputTuple, output);
openedFullType = refType;
return true;
@@ -1586,7 +1586,7 @@ resolveOverloadForDeclWithSpecialTypeCheckingSemantics(ConstraintSystem &CS,
CS.getConstraintLocator(locator, ConstraintLocator::FunctionArgument));
CS.addConstraint(ConstraintKind::EscapableFunctionOf,
escapeClosure, noescapeClosure,
CS.getConstraintLocator(locator, ConstraintLocator::RvalueAdjustment));
CS.getConstraintLocator(locator, ConstraintLocator::RValueAdjustment));
auto result = CS.createTypeVariable(
CS.getConstraintLocator(locator, ConstraintLocator::FunctionResult));
auto bodyClosure = FunctionType::get(
@@ -1618,7 +1618,7 @@ resolveOverloadForDeclWithSpecialTypeCheckingSemantics(ConstraintSystem &CS,
CS.getConstraintLocator(locator, ConstraintLocator::FunctionArgument));
CS.addConstraint(ConstraintKind::OpenedExistentialOf,
openedTy, existentialTy,
CS.getConstraintLocator(locator, ConstraintLocator::RvalueAdjustment));
CS.getConstraintLocator(locator, ConstraintLocator::RValueAdjustment));
auto result = CS.createTypeVariable(
CS.getConstraintLocator(locator, ConstraintLocator::FunctionResult));
auto bodyClosure = FunctionType::get(