Skip to content

[NFC] Rename @lvalue Locator Path Element #16860

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 1 commit into from
May 27, 2018
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
5 changes: 3 additions & 2 deletions lib/Sema/CSDiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions lib/Sema/CSGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.
Expand Down Expand Up @@ -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;
}

Expand Down
8 changes: 4 additions & 4 deletions lib/Sema/CSSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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");
Expand Down Expand Up @@ -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));
}
}

Expand Down Expand Up @@ -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));
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions lib/Sema/ConstraintLocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
17 changes: 9 additions & 8 deletions lib/Sema/ConstraintLocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,11 @@ class ConstraintLocator : public llvm::FoldingSetNode {
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.
Expand All @@ -107,8 +110,6 @@ class ConstraintLocator : public llvm::FoldingSetNode {
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
Expand Down Expand Up @@ -152,13 +153,13 @@ class ConstraintLocator : public llvm::FoldingSetNode {
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:
Expand Down Expand Up @@ -202,7 +203,6 @@ class ConstraintLocator : public llvm::FoldingSetNode {
case ApplyArgToParam:
case SequenceIteratorProtocol:
case GeneratorElementType:
case ArrayElementType:
case ClosureResult:
case ConstructorMember:
case InstanceType:
Expand All @@ -212,7 +212,8 @@ class ConstraintLocator : public llvm::FoldingSetNode {
case MemberRefBase:
case UnresolvedMember:
case ParentType:
case RvalueAdjustment:
case LValueConversion:
case RValueAdjustment:
case ScalarToTuple:
case SubscriptIndex:
case SubscriptMember:
Expand Down
6 changes: 3 additions & 3 deletions lib/Sema/ConstraintSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down