mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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:
@@ -195,10 +195,11 @@ void constraints::simplifyLocator(Expr *&anchor,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ConstraintLocator::AutoclosureResult:
|
case ConstraintLocator::AutoclosureResult:
|
||||||
case ConstraintLocator::RvalueAdjustment:
|
case ConstraintLocator::LValueConversion:
|
||||||
|
case ConstraintLocator::RValueAdjustment:
|
||||||
case ConstraintLocator::ScalarToTuple:
|
case ConstraintLocator::ScalarToTuple:
|
||||||
case ConstraintLocator::UnresolvedMember:
|
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
|
// scalar-to-tuple conversions, and unresolved members are
|
||||||
// implicit.
|
// implicit.
|
||||||
path = path.slice(1);
|
path = path.slice(1);
|
||||||
|
|||||||
@@ -1487,12 +1487,12 @@ namespace {
|
|||||||
// If there is an argument, apply it.
|
// If there is an argument, apply it.
|
||||||
if (auto arg = expr->getArgument()) {
|
if (auto arg = expr->getArgument()) {
|
||||||
// The result type of the function must be convertible to the base type.
|
// The result type of the function must be convertible to the base type.
|
||||||
// TODO: we definitely want this to include ImplicitlyUnwrappedOptional; does it
|
// TODO: we definitely want this to include ImplicitlyUnwrappedOptional;
|
||||||
// need to include everything else in the world?
|
// does it need to include everything else in the world?
|
||||||
auto outputTy = CS.createTypeVariable(
|
auto outputTy = CS.createTypeVariable(
|
||||||
CS.getConstraintLocator(expr, ConstraintLocator::FunctionResult));
|
CS.getConstraintLocator(expr, ConstraintLocator::FunctionResult));
|
||||||
CS.addConstraint(ConstraintKind::Conversion, outputTy, baseTy,
|
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.
|
// The function/enum case must be callable with the given argument.
|
||||||
auto funcTy = FunctionType::get(CS.getType(arg), outputTy);
|
auto funcTy = FunctionType::get(CS.getType(arg), outputTy);
|
||||||
@@ -1505,7 +1505,7 @@ namespace {
|
|||||||
|
|
||||||
// Otherwise, the member needs to be convertible to the base type.
|
// Otherwise, the member needs to be convertible to the base type.
|
||||||
CS.addConstraint(ConstraintKind::Conversion, memberTy, baseTy,
|
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
|
// The member type also needs to be convertible to the context type, which
|
||||||
// preserves lvalue-ness.
|
// preserves lvalue-ness.
|
||||||
@@ -2388,7 +2388,7 @@ namespace {
|
|||||||
auto tv = CS.createTypeVariable(CS.getConstraintLocator(expr));
|
auto tv = CS.createTypeVariable(CS.getConstraintLocator(expr));
|
||||||
CS.addConstraint(ConstraintKind::DynamicTypeOf, tv,
|
CS.addConstraint(ConstraintKind::DynamicTypeOf, tv,
|
||||||
CS.getType(expr->getBase()),
|
CS.getType(expr->getBase()),
|
||||||
CS.getConstraintLocator(expr, ConstraintLocator::RvalueAdjustment));
|
CS.getConstraintLocator(expr, ConstraintLocator::RValueAdjustment));
|
||||||
return tv;
|
return tv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1925,7 +1925,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
|
|||||||
cast<LValueType>(desugar2)->getObjectType(),
|
cast<LValueType>(desugar2)->getObjectType(),
|
||||||
ConstraintKind::Equal, subflags,
|
ConstraintKind::Equal, subflags,
|
||||||
locator.withPathElement(
|
locator.withPathElement(
|
||||||
ConstraintLocator::ArrayElementType));
|
ConstraintLocator::LValueConversion));
|
||||||
|
|
||||||
case TypeKind::InOut:
|
case TypeKind::InOut:
|
||||||
// If the RHS is an inout type, the LHS must be an @lvalue type.
|
// 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(),
|
return matchTypes(cast<InOutType>(desugar1)->getObjectType(),
|
||||||
cast<InOutType>(desugar2)->getObjectType(),
|
cast<InOutType>(desugar2)->getObjectType(),
|
||||||
ConstraintKind::Equal, subflags,
|
ConstraintKind::Equal, subflags,
|
||||||
locator.withPathElement(ConstraintLocator::ArrayElementType));
|
locator.withPathElement(ConstraintLocator::LValueConversion));
|
||||||
|
|
||||||
case TypeKind::UnboundGeneric:
|
case TypeKind::UnboundGeneric:
|
||||||
llvm_unreachable("Unbound generic type should have been opened");
|
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()),
|
return matchTypes(type1, LValueType::get(iot->getObjectType()),
|
||||||
kind, subflags,
|
kind, subflags,
|
||||||
locator.withPathElement(
|
locator.withPathElement(
|
||||||
ConstraintLocator::ArrayElementType));
|
ConstraintLocator::LValueConversion));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2337,7 +2337,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
|
|||||||
return matchTypes(iot->getObjectType(), lvt->getObjectType(),
|
return matchTypes(iot->getObjectType(), lvt->getObjectType(),
|
||||||
ConstraintKind::Bind, subflags,
|
ConstraintKind::Bind, subflags,
|
||||||
locator.withPathElement(
|
locator.withPathElement(
|
||||||
ConstraintLocator::ArrayElementType));
|
ConstraintLocator::LValueConversion));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,13 +61,13 @@ void ConstraintLocator::Profile(llvm::FoldingSetNodeID &id, Expr *anchor,
|
|||||||
case SubscriptMember:
|
case SubscriptMember:
|
||||||
case SubscriptResult:
|
case SubscriptResult:
|
||||||
case ConstructorMember:
|
case ConstructorMember:
|
||||||
case RvalueAdjustment:
|
case LValueConversion:
|
||||||
|
case RValueAdjustment:
|
||||||
case ClosureResult:
|
case ClosureResult:
|
||||||
case ParentType:
|
case ParentType:
|
||||||
case InstanceType:
|
case InstanceType:
|
||||||
case SequenceIteratorProtocol:
|
case SequenceIteratorProtocol:
|
||||||
case GeneratorElementType:
|
case GeneratorElementType:
|
||||||
case ArrayElementType:
|
|
||||||
case ScalarToTuple:
|
case ScalarToTuple:
|
||||||
case AutoclosureResult:
|
case AutoclosureResult:
|
||||||
case GenericArgument:
|
case GenericArgument:
|
||||||
@@ -115,10 +115,6 @@ void ConstraintLocator::dump(SourceManager *sm, raw_ostream &out) {
|
|||||||
for (auto elt : getPath()) {
|
for (auto elt : getPath()) {
|
||||||
out << " -> ";
|
out << " -> ";
|
||||||
switch (elt.getKind()) {
|
switch (elt.getKind()) {
|
||||||
case ArrayElementType:
|
|
||||||
out << "array element";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Archetype:
|
case Archetype:
|
||||||
out << "archetype '" << elt.getArchetype()->getString() << "'";
|
out << "archetype '" << elt.getArchetype()->getString() << "'";
|
||||||
break;
|
break;
|
||||||
@@ -197,7 +193,11 @@ void ConstraintLocator::dump(SourceManager *sm, raw_ostream &out) {
|
|||||||
out << "parent type";
|
out << "parent type";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RvalueAdjustment:
|
case LValueConversion:
|
||||||
|
out << "@lvalue-to-inout conversion";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RValueAdjustment:
|
||||||
out << "rvalue adjustment";
|
out << "rvalue adjustment";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -95,8 +95,11 @@ public:
|
|||||||
SubscriptResult,
|
SubscriptResult,
|
||||||
/// \brief The lookup for a constructor member.
|
/// \brief The lookup for a constructor member.
|
||||||
ConstructorMember,
|
ConstructorMember,
|
||||||
/// \brief Rvalue adjustment.
|
/// \brief An implicit @lvalue-to-inout conversion; only valid for operator
|
||||||
RvalueAdjustment,
|
/// arguments.
|
||||||
|
LValueConversion,
|
||||||
|
/// \brief RValue adjustment.
|
||||||
|
RValueAdjustment,
|
||||||
/// \brief The result of a closure.
|
/// \brief The result of a closure.
|
||||||
ClosureResult,
|
ClosureResult,
|
||||||
/// \brief The parent of a nested type.
|
/// \brief The parent of a nested type.
|
||||||
@@ -107,8 +110,6 @@ public:
|
|||||||
SequenceIteratorProtocol,
|
SequenceIteratorProtocol,
|
||||||
/// \brief The element type of a generator.
|
/// \brief The element type of a generator.
|
||||||
GeneratorElementType,
|
GeneratorElementType,
|
||||||
/// \brief The element of an array type.
|
|
||||||
ArrayElementType,
|
|
||||||
/// \brief The scalar type of a tuple type.
|
/// \brief The scalar type of a tuple type.
|
||||||
ScalarToTuple,
|
ScalarToTuple,
|
||||||
/// \brief An argument passed in an autoclosure parameter
|
/// \brief An argument passed in an autoclosure parameter
|
||||||
@@ -152,13 +153,13 @@ public:
|
|||||||
case SubscriptMember:
|
case SubscriptMember:
|
||||||
case SubscriptResult:
|
case SubscriptResult:
|
||||||
case ConstructorMember:
|
case ConstructorMember:
|
||||||
case RvalueAdjustment:
|
case LValueConversion:
|
||||||
|
case RValueAdjustment:
|
||||||
case ClosureResult:
|
case ClosureResult:
|
||||||
case ParentType:
|
case ParentType:
|
||||||
case InstanceType:
|
case InstanceType:
|
||||||
case SequenceIteratorProtocol:
|
case SequenceIteratorProtocol:
|
||||||
case GeneratorElementType:
|
case GeneratorElementType:
|
||||||
case ArrayElementType:
|
|
||||||
case ScalarToTuple:
|
case ScalarToTuple:
|
||||||
case AutoclosureResult:
|
case AutoclosureResult:
|
||||||
case Requirement:
|
case Requirement:
|
||||||
@@ -202,7 +203,6 @@ public:
|
|||||||
case ApplyArgToParam:
|
case ApplyArgToParam:
|
||||||
case SequenceIteratorProtocol:
|
case SequenceIteratorProtocol:
|
||||||
case GeneratorElementType:
|
case GeneratorElementType:
|
||||||
case ArrayElementType:
|
|
||||||
case ClosureResult:
|
case ClosureResult:
|
||||||
case ConstructorMember:
|
case ConstructorMember:
|
||||||
case InstanceType:
|
case InstanceType:
|
||||||
@@ -212,7 +212,8 @@ public:
|
|||||||
case MemberRefBase:
|
case MemberRefBase:
|
||||||
case UnresolvedMember:
|
case UnresolvedMember:
|
||||||
case ParentType:
|
case ParentType:
|
||||||
case RvalueAdjustment:
|
case LValueConversion:
|
||||||
|
case RValueAdjustment:
|
||||||
case ScalarToTuple:
|
case ScalarToTuple:
|
||||||
case SubscriptIndex:
|
case SubscriptIndex:
|
||||||
case SubscriptMember:
|
case SubscriptMember:
|
||||||
|
|||||||
@@ -1571,7 +1571,7 @@ resolveOverloadForDeclWithSpecialTypeCheckingSemantics(ConstraintSystem &CS,
|
|||||||
auto inputTuple = TupleType::get(inputArg, CS.getASTContext());
|
auto inputTuple = TupleType::get(inputArg, CS.getASTContext());
|
||||||
|
|
||||||
CS.addConstraint(ConstraintKind::DynamicTypeOf, output, input,
|
CS.addConstraint(ConstraintKind::DynamicTypeOf, output, input,
|
||||||
CS.getConstraintLocator(locator, ConstraintLocator::RvalueAdjustment));
|
CS.getConstraintLocator(locator, ConstraintLocator::RValueAdjustment));
|
||||||
refType = FunctionType::get(inputTuple, output);
|
refType = FunctionType::get(inputTuple, output);
|
||||||
openedFullType = refType;
|
openedFullType = refType;
|
||||||
return true;
|
return true;
|
||||||
@@ -1586,7 +1586,7 @@ resolveOverloadForDeclWithSpecialTypeCheckingSemantics(ConstraintSystem &CS,
|
|||||||
CS.getConstraintLocator(locator, ConstraintLocator::FunctionArgument));
|
CS.getConstraintLocator(locator, ConstraintLocator::FunctionArgument));
|
||||||
CS.addConstraint(ConstraintKind::EscapableFunctionOf,
|
CS.addConstraint(ConstraintKind::EscapableFunctionOf,
|
||||||
escapeClosure, noescapeClosure,
|
escapeClosure, noescapeClosure,
|
||||||
CS.getConstraintLocator(locator, ConstraintLocator::RvalueAdjustment));
|
CS.getConstraintLocator(locator, ConstraintLocator::RValueAdjustment));
|
||||||
auto result = CS.createTypeVariable(
|
auto result = CS.createTypeVariable(
|
||||||
CS.getConstraintLocator(locator, ConstraintLocator::FunctionResult));
|
CS.getConstraintLocator(locator, ConstraintLocator::FunctionResult));
|
||||||
auto bodyClosure = FunctionType::get(
|
auto bodyClosure = FunctionType::get(
|
||||||
@@ -1618,7 +1618,7 @@ resolveOverloadForDeclWithSpecialTypeCheckingSemantics(ConstraintSystem &CS,
|
|||||||
CS.getConstraintLocator(locator, ConstraintLocator::FunctionArgument));
|
CS.getConstraintLocator(locator, ConstraintLocator::FunctionArgument));
|
||||||
CS.addConstraint(ConstraintKind::OpenedExistentialOf,
|
CS.addConstraint(ConstraintKind::OpenedExistentialOf,
|
||||||
openedTy, existentialTy,
|
openedTy, existentialTy,
|
||||||
CS.getConstraintLocator(locator, ConstraintLocator::RvalueAdjustment));
|
CS.getConstraintLocator(locator, ConstraintLocator::RValueAdjustment));
|
||||||
auto result = CS.createTypeVariable(
|
auto result = CS.createTypeVariable(
|
||||||
CS.getConstraintLocator(locator, ConstraintLocator::FunctionResult));
|
CS.getConstraintLocator(locator, ConstraintLocator::FunctionResult));
|
||||||
auto bodyClosure = FunctionType::get(
|
auto bodyClosure = FunctionType::get(
|
||||||
|
|||||||
Reference in New Issue
Block a user