mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #15580 from davezarzycki/remove_majority_of_TVO_CanBindToInOut
[Sema] Remove unneeded uses of TVO_CanBindToInOut
This commit is contained in:
@@ -4802,7 +4802,6 @@ namespace {
|
||||
|
||||
auto tv = cs.createTypeVariable(inputLocator,
|
||||
TVO_CanBindToLValue |
|
||||
TVO_CanBindToInOut |
|
||||
TVO_PrefersSubtypeBinding);
|
||||
|
||||
// In order to make this work, we pick the most general function type and
|
||||
@@ -5254,9 +5253,8 @@ bool FailureDiagnosis::diagnoseTrailingClosureErrors(ApplyExpr *callExpr) {
|
||||
cs.addConstraint(ConstraintKind::Conversion, fnType->getResult(),
|
||||
expectedResultType, locator);
|
||||
} else if (auto *typeVar = resultType->getAs<TypeVariableType>()) {
|
||||
auto tv =
|
||||
cs.createTypeVariable(cs.getConstraintLocator(expr),
|
||||
TVO_CanBindToLValue | TVO_CanBindToInOut |
|
||||
auto tv = cs.createTypeVariable(cs.getConstraintLocator(expr),
|
||||
TVO_CanBindToLValue |
|
||||
TVO_PrefersSubtypeBinding);
|
||||
|
||||
auto extInfo = FunctionType::ExtInfo().withThrows();
|
||||
@@ -7073,7 +7071,7 @@ bool FailureDiagnosis::visitKeyPathExpr(KeyPathExpr *KPE) {
|
||||
|
||||
bool builtConstraints(ConstraintSystem &cs, Expr *expr) override {
|
||||
auto *locator = cs.getConstraintLocator(expr);
|
||||
auto valueType = cs.createTypeVariable(locator, TVO_CanBindToInOut);
|
||||
auto valueType = cs.createTypeVariable(locator, /*options*/0);
|
||||
|
||||
auto keyPathType =
|
||||
BoundGenericClassType::get(Decl, ParentType, {RootType, valueType});
|
||||
|
||||
@@ -985,8 +985,7 @@ namespace {
|
||||
auto baseTy = CS.getType(base);
|
||||
auto tv = CS.createTypeVariable(
|
||||
CS.getConstraintLocator(expr, ConstraintLocator::Member),
|
||||
TVO_CanBindToLValue |
|
||||
TVO_CanBindToInOut);
|
||||
TVO_CanBindToLValue);
|
||||
CS.addValueMemberConstraint(baseTy, name, tv, CurDC, functionRefKind,
|
||||
CS.getConstraintLocator(expr, ConstraintLocator::Member));
|
||||
return tv;
|
||||
@@ -1006,9 +1005,7 @@ namespace {
|
||||
|
||||
auto memberLocator =
|
||||
CS.getConstraintLocator(expr, ConstraintLocator::Member);
|
||||
auto tv = CS.createTypeVariable(memberLocator,
|
||||
TVO_CanBindToLValue |
|
||||
TVO_CanBindToInOut);
|
||||
auto tv = CS.createTypeVariable(memberLocator, TVO_CanBindToLValue);
|
||||
|
||||
OverloadChoice choice =
|
||||
OverloadChoice(CS.getType(base), decl, functionRefKind);
|
||||
@@ -1036,7 +1033,7 @@ namespace {
|
||||
// I -> inout? O, where I and O are fresh type variables. The index
|
||||
// expression must be convertible to I and the subscript expression
|
||||
// itself has type inout? O, where O may or may not be an lvalue.
|
||||
auto inputTv = CS.createTypeVariable(indexLocator, TVO_CanBindToInOut);
|
||||
auto inputTv = CS.createTypeVariable(indexLocator, /*options*/0);
|
||||
|
||||
// For an integer subscript expression on an array slice type, instead of
|
||||
// introducing a new type variable we can easily obtain the element type.
|
||||
@@ -1083,9 +1080,7 @@ namespace {
|
||||
}
|
||||
|
||||
if (outputTy.isNull()) {
|
||||
outputTy = CS.createTypeVariable(resultLocator,
|
||||
TVO_CanBindToLValue |
|
||||
TVO_CanBindToInOut);
|
||||
outputTy = CS.createTypeVariable(resultLocator, TVO_CanBindToLValue);
|
||||
} else {
|
||||
// TODO: Generalize this for non-subscript-expr anchors, so that e.g.
|
||||
// keypath lookup benefits from the peephole as well.
|
||||
@@ -1174,8 +1169,7 @@ namespace {
|
||||
|
||||
|
||||
auto tv = CS.createTypeVariable(CS.getConstraintLocator(expr),
|
||||
TVO_PrefersSubtypeBinding |
|
||||
TVO_CanBindToInOut);
|
||||
TVO_PrefersSubtypeBinding);
|
||||
CS.addConstraint(ConstraintKind::LiteralConformsTo, tv,
|
||||
protocol->getDeclaredType(),
|
||||
CS.getConstraintLocator(expr));
|
||||
@@ -1197,9 +1191,7 @@ namespace {
|
||||
// The type of the expression must conform to the
|
||||
// ExpressibleByStringInterpolation protocol.
|
||||
auto locator = CS.getConstraintLocator(expr);
|
||||
auto tv = CS.createTypeVariable(locator,
|
||||
TVO_PrefersSubtypeBinding |
|
||||
TVO_CanBindToInOut);
|
||||
auto tv = CS.createTypeVariable(locator, TVO_PrefersSubtypeBinding);
|
||||
CS.addConstraint(ConstraintKind::LiteralConformsTo, tv,
|
||||
interpolationProto->getDeclaredType(),
|
||||
locator);
|
||||
@@ -1244,8 +1236,7 @@ namespace {
|
||||
}
|
||||
|
||||
auto tv = CS.createTypeVariable(CS.getConstraintLocator(expr),
|
||||
TVO_PrefersSubtypeBinding |
|
||||
TVO_CanBindToInOut);
|
||||
TVO_PrefersSubtypeBinding);
|
||||
|
||||
CS.addConstraint(ConstraintKind::LiteralConformsTo, tv,
|
||||
protocol->getDeclaredType(),
|
||||
@@ -1288,8 +1279,7 @@ namespace {
|
||||
if (VD->hasInterfaceType() &&
|
||||
VD->getInterfaceType()->is<UnresolvedType>()) {
|
||||
return CS.createTypeVariable(CS.getConstraintLocator(E),
|
||||
TVO_CanBindToLValue |
|
||||
TVO_CanBindToInOut);
|
||||
TVO_CanBindToLValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1375,9 +1365,7 @@ namespace {
|
||||
// that will be equal to different types depending on which overload
|
||||
// is selected.
|
||||
auto locator = CS.getConstraintLocator(expr);
|
||||
auto tv = CS.createTypeVariable(locator,
|
||||
TVO_CanBindToLValue |
|
||||
TVO_CanBindToInOut);
|
||||
auto tv = CS.createTypeVariable(locator, TVO_CanBindToLValue);
|
||||
ArrayRef<ValueDecl*> decls = expr->getDecls();
|
||||
SmallVector<OverloadChoice, 4> choices;
|
||||
|
||||
@@ -1408,8 +1396,7 @@ namespace {
|
||||
// to help us determine which declaration the user meant to refer to.
|
||||
// FIXME: Do we need to note that we're doing some kind of recovery?
|
||||
return CS.createTypeVariable(CS.getConstraintLocator(expr),
|
||||
TVO_CanBindToLValue |
|
||||
TVO_CanBindToInOut);
|
||||
TVO_CanBindToLValue);
|
||||
}
|
||||
|
||||
Type visitMemberRefExpr(MemberRefExpr *expr) {
|
||||
@@ -1434,10 +1421,8 @@ namespace {
|
||||
|
||||
auto memberLocator
|
||||
= CS.getConstraintLocator(expr, ConstraintLocator::UnresolvedMember);
|
||||
auto baseTy = CS.createTypeVariable(baseLocator, TVO_CanBindToInOut);
|
||||
auto memberTy = CS.createTypeVariable(memberLocator,
|
||||
TVO_CanBindToLValue |
|
||||
TVO_CanBindToInOut);
|
||||
auto baseTy = CS.createTypeVariable(baseLocator, /*options*/0);
|
||||
auto memberTy = CS.createTypeVariable(memberLocator, TVO_CanBindToLValue);
|
||||
|
||||
// An unresolved member expression '.member' is modeled as a value member
|
||||
// constraint
|
||||
@@ -1458,7 +1443,7 @@ namespace {
|
||||
// need to include everything else in the world?
|
||||
auto outputTy = CS.createTypeVariable(
|
||||
CS.getConstraintLocator(expr, ConstraintLocator::FunctionResult),
|
||||
TVO_CanBindToInOut);
|
||||
/*options*/0);
|
||||
CS.addConstraint(ConstraintKind::Conversion, outputTy, baseTy,
|
||||
CS.getConstraintLocator(expr, ConstraintLocator::RvalueAdjustment));
|
||||
|
||||
@@ -1477,9 +1462,7 @@ namespace {
|
||||
|
||||
// The member type also needs to be convertible to the context type, which
|
||||
// preserves lvalue-ness.
|
||||
auto resultTy = CS.createTypeVariable(memberLocator,
|
||||
TVO_CanBindToLValue |
|
||||
TVO_CanBindToInOut);
|
||||
auto resultTy = CS.createTypeVariable(memberLocator, TVO_CanBindToLValue);
|
||||
CS.addConstraint(ConstraintKind::Conversion, memberTy, resultTy,
|
||||
memberLocator);
|
||||
CS.addConstraint(ConstraintKind::Equal, resultTy, baseTy,
|
||||
@@ -1513,10 +1496,9 @@ namespace {
|
||||
auto argsTy = CS.createTypeVariable(
|
||||
CS.getConstraintLocator(expr),
|
||||
TVO_CanBindToLValue |
|
||||
TVO_PrefersSubtypeBinding |
|
||||
TVO_CanBindToInOut);
|
||||
TVO_PrefersSubtypeBinding);
|
||||
auto resultTy = CS.createTypeVariable(CS.getConstraintLocator(expr),
|
||||
TVO_CanBindToInOut);
|
||||
/*options*/0);
|
||||
auto methodTy = FunctionType::get(argsTy, resultTy);
|
||||
CS.addValueMemberConstraint(baseTy, expr->getName(),
|
||||
methodTy, CurDC, expr->getFunctionRefKind(),
|
||||
@@ -1620,8 +1602,7 @@ namespace {
|
||||
|
||||
Type visitOptionalTryExpr(OptionalTryExpr *expr) {
|
||||
auto valueTy = CS.createTypeVariable(CS.getConstraintLocator(expr),
|
||||
TVO_PrefersSubtypeBinding |
|
||||
TVO_CanBindToInOut);
|
||||
TVO_PrefersSubtypeBinding);
|
||||
|
||||
Type optTy = getOptionalType(expr->getSubExpr()->getLoc(), valueTy);
|
||||
if (!optTy)
|
||||
@@ -1722,9 +1703,7 @@ namespace {
|
||||
return contextualArrayType;
|
||||
}
|
||||
|
||||
auto arrayTy = CS.createTypeVariable(locator,
|
||||
TVO_PrefersSubtypeBinding |
|
||||
TVO_CanBindToInOut);
|
||||
auto arrayTy = CS.createTypeVariable(locator, TVO_PrefersSubtypeBinding);
|
||||
|
||||
// The array must be an array literal type.
|
||||
CS.addConstraint(ConstraintKind::LiteralConformsTo, arrayTy,
|
||||
@@ -1820,8 +1799,7 @@ namespace {
|
||||
}
|
||||
|
||||
auto dictionaryTy = CS.createTypeVariable(locator,
|
||||
TVO_PrefersSubtypeBinding |
|
||||
TVO_CanBindToInOut);
|
||||
TVO_PrefersSubtypeBinding);
|
||||
|
||||
// The dictionary must be a dictionary literal type.
|
||||
CS.addConstraint(ConstraintKind::LiteralConformsTo, dictionaryTy,
|
||||
@@ -1997,7 +1975,7 @@ namespace {
|
||||
}
|
||||
|
||||
return CS.createTypeVariable(CS.getConstraintLocator(locator),
|
||||
TVO_CanBindToInOut);
|
||||
/*options*/0);
|
||||
}
|
||||
|
||||
case PatternKind::Named: {
|
||||
@@ -2314,7 +2292,7 @@ namespace {
|
||||
|
||||
// If no return type was specified, create a fresh type
|
||||
// variable for it.
|
||||
funcTy = CS.createTypeVariable(locator, TVO_CanBindToInOut);
|
||||
funcTy = CS.createTypeVariable(locator, /*options*/0);
|
||||
|
||||
// Allow it to default to () if there are no return statements.
|
||||
if (closureHasNoResult(expr)) {
|
||||
@@ -2363,7 +2341,7 @@ namespace {
|
||||
|
||||
Type visitDynamicTypeExpr(DynamicTypeExpr *expr) {
|
||||
auto tv = CS.createTypeVariable(CS.getConstraintLocator(expr),
|
||||
TVO_CanBindToInOut);
|
||||
/*options*/0);
|
||||
CS.addConstraint(ConstraintKind::DynamicTypeOf, tv,
|
||||
CS.getType(expr->getBase()),
|
||||
CS.getConstraintLocator(expr, ConstraintLocator::RvalueAdjustment));
|
||||
@@ -2441,7 +2419,7 @@ namespace {
|
||||
if (outputTy.isNull()) {
|
||||
outputTy = CS.createTypeVariable(
|
||||
CS.getConstraintLocator(expr, ConstraintLocator::FunctionResult),
|
||||
TVO_CanBindToInOut);
|
||||
/*options*/0);
|
||||
} else {
|
||||
// Since we know what the output type is, we can set it as the favored
|
||||
// type of this expression.
|
||||
@@ -2694,9 +2672,7 @@ namespace {
|
||||
// just plop an open type variable here.
|
||||
|
||||
auto locator = CS.getConstraintLocator(expr);
|
||||
auto typeVar = CS.createTypeVariable(locator,
|
||||
TVO_CanBindToLValue |
|
||||
TVO_CanBindToInOut);
|
||||
auto typeVar = CS.createTypeVariable(locator, TVO_CanBindToLValue);
|
||||
return typeVar;
|
||||
}
|
||||
|
||||
@@ -2719,8 +2695,7 @@ namespace {
|
||||
|
||||
auto objectTy = CS.createTypeVariable(locator,
|
||||
TVO_PrefersSubtypeBinding |
|
||||
TVO_CanBindToLValue |
|
||||
TVO_CanBindToInOut);
|
||||
TVO_CanBindToLValue);
|
||||
|
||||
// The result is the object type of the optional subexpression.
|
||||
CS.addConstraint(ConstraintKind::OptionalObject,
|
||||
@@ -2735,8 +2710,7 @@ namespace {
|
||||
// optional types, e.g. T? over T??; otherwise we don't really
|
||||
// have a preference.
|
||||
auto valueTy = CS.createTypeVariable(CS.getConstraintLocator(expr),
|
||||
TVO_PrefersSubtypeBinding |
|
||||
TVO_CanBindToInOut);
|
||||
TVO_PrefersSubtypeBinding);
|
||||
|
||||
Type optTy = getOptionalType(expr->getSubExpr()->getLoc(), valueTy);
|
||||
if (!optTy)
|
||||
@@ -2754,8 +2728,7 @@ namespace {
|
||||
|
||||
auto objectTy = CS.createTypeVariable(locator,
|
||||
TVO_PrefersSubtypeBinding |
|
||||
TVO_CanBindToLValue |
|
||||
TVO_CanBindToInOut);
|
||||
TVO_CanBindToLValue);
|
||||
|
||||
// The result is the object type of the optional subexpression.
|
||||
CS.addConstraint(ConstraintKind::OptionalObject,
|
||||
@@ -2796,7 +2769,7 @@ namespace {
|
||||
auto &placeholderTy
|
||||
= editorPlaceholderVariables[currentEditorPlaceholderVariable];
|
||||
if (!placeholderTy) {
|
||||
placeholderTy = CS.createTypeVariable(locator, TVO_CanBindToInOut);
|
||||
placeholderTy = CS.createTypeVariable(locator, /*options*/0);
|
||||
|
||||
CS.addConstraint(ConstraintKind::Defaultable,
|
||||
placeholderTy,
|
||||
@@ -2852,7 +2825,7 @@ namespace {
|
||||
// For native key paths, traverse the key path components to set up
|
||||
// appropriate type relationships at each level.
|
||||
auto locator = CS.getConstraintLocator(E);
|
||||
Type root = CS.createTypeVariable(locator, TVO_CanBindToInOut);
|
||||
Type root = CS.createTypeVariable(locator, /*options*/0);
|
||||
|
||||
// If a root type was explicitly given, then resolve it now.
|
||||
if (auto rootRepr = E->getRootType()) {
|
||||
@@ -2878,9 +2851,7 @@ namespace {
|
||||
// This should only appear in resolved ASTs, but we may need to
|
||||
// re-type-check the constraints during failure diagnosis.
|
||||
case KeyPathExpr::Component::Kind::Property: {
|
||||
auto memberTy = CS.createTypeVariable(locator,
|
||||
TVO_CanBindToLValue |
|
||||
TVO_CanBindToInOut);
|
||||
auto memberTy = CS.createTypeVariable(locator, TVO_CanBindToLValue);
|
||||
auto lookupName = kind == KeyPathExpr::Component::Kind::UnresolvedProperty
|
||||
? component.getUnresolvedDeclName()
|
||||
: component.getDeclRef().getDecl()->getFullName();
|
||||
@@ -2924,8 +2895,7 @@ namespace {
|
||||
}
|
||||
case KeyPathExpr::Component::Kind::OptionalForce: {
|
||||
auto optionalObjTy = CS.createTypeVariable(locator,
|
||||
TVO_CanBindToLValue |
|
||||
TVO_CanBindToInOut);
|
||||
TVO_CanBindToLValue);
|
||||
|
||||
CS.addConstraint(ConstraintKind::OptionalObject, base, optionalObjTy,
|
||||
locator);
|
||||
@@ -2946,14 +2916,14 @@ namespace {
|
||||
// If there was an optional chaining component, the end result must be
|
||||
// optional.
|
||||
if (didOptionalChain) {
|
||||
auto objTy = CS.createTypeVariable(locator, TVO_CanBindToInOut);
|
||||
auto objTy = CS.createTypeVariable(locator, /*options*/0);
|
||||
auto optTy = OptionalType::get(objTy);
|
||||
CS.addConstraint(ConstraintKind::Conversion, base, optTy,
|
||||
locator);
|
||||
base = optTy;
|
||||
}
|
||||
|
||||
auto rvalueBase = CS.createTypeVariable(locator, TVO_CanBindToInOut);
|
||||
auto rvalueBase = CS.createTypeVariable(locator, /*options*/0);
|
||||
CS.addConstraint(ConstraintKind::Equal, base, rvalueBase, locator);
|
||||
|
||||
// The result is a KeyPath from the root to the end component.
|
||||
@@ -2965,7 +2935,7 @@ namespace {
|
||||
// The type of key path depends on the overloads chosen for the key
|
||||
// path components.
|
||||
kpTy = CS.createTypeVariable(CS.getConstraintLocator(E),
|
||||
TVO_CanBindToInOut);
|
||||
/*options*/0);
|
||||
CS.addKeyPathConstraint(kpTy, root, rvalueBase,
|
||||
CS.getConstraintLocator(E));
|
||||
}
|
||||
@@ -3433,8 +3403,7 @@ class InferUnresolvedMemberConstraintGenerator : public ConstraintGenerator {
|
||||
TypeVariableType *createFreeTypeVariableType(Expr *E) {
|
||||
auto &CS = getConstraintSystem();
|
||||
return CS.createTypeVariable(CS.getConstraintLocator(nullptr),
|
||||
TVO_CanBindToLValue |
|
||||
TVO_CanBindToInOut);
|
||||
TVO_CanBindToLValue);
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -3664,9 +3633,7 @@ swift::resolveValueMember(DeclContext &DC, Type BaseTy, DeclName Name) {
|
||||
|
||||
// Try to figure out the best overload.
|
||||
ConstraintLocator *Locator = CS.getConstraintLocator(nullptr);
|
||||
TypeVariableType *TV = CS.createTypeVariable(Locator,
|
||||
TVO_CanBindToLValue |
|
||||
TVO_CanBindToInOut);
|
||||
TypeVariableType *TV = CS.createTypeVariable(Locator, TVO_CanBindToLValue);
|
||||
CS.addOverloadSet(TV, LookupResult.ViableCandidates, &DC, Locator);
|
||||
Optional<Solution> OpSolution = CS.solveSingle();
|
||||
ValueDecl *Selected = nullptr;
|
||||
|
||||
@@ -2542,7 +2542,6 @@ ConstraintSystem::simplifyConstructionConstraint(
|
||||
ConstraintLocator::ApplyFunction);
|
||||
auto tv = createTypeVariable(applyLocator,
|
||||
TVO_CanBindToLValue |
|
||||
TVO_CanBindToInOut |
|
||||
TVO_PrefersSubtypeBinding);
|
||||
|
||||
// The constructor will have function type T -> T2, for a fresh type
|
||||
@@ -4701,9 +4700,7 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
|
||||
return SolutionKind::Error;
|
||||
|
||||
auto constraintLocator = getConstraintLocator(locator);
|
||||
auto tv = createTypeVariable(constraintLocator,
|
||||
TVO_PrefersSubtypeBinding |
|
||||
TVO_CanBindToInOut);
|
||||
auto tv = createTypeVariable(constraintLocator, TVO_PrefersSubtypeBinding);
|
||||
|
||||
addConstraint(ConstraintKind::ConformsTo, tv,
|
||||
hashableProtocol->getDeclaredType(), constraintLocator);
|
||||
|
||||
@@ -1364,8 +1364,7 @@ ConstraintSystem::solve(Expr *&expr,
|
||||
if (allowFreeTypeVariables == FreeTypeVariableBinding::UnresolvedType) {
|
||||
convertType = convertType.transform([&](Type type) -> Type {
|
||||
if (type->is<UnresolvedType>())
|
||||
return createTypeVariable(getConstraintLocator(expr),
|
||||
TVO_CanBindToInOut);
|
||||
return createTypeVariable(getConstraintLocator(expr), /*options*/0);
|
||||
return type;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -941,8 +941,7 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value,
|
||||
return { found->second, found->second };
|
||||
|
||||
auto typeVar = createTypeVariable(getConstraintLocator(locator),
|
||||
TVO_CanBindToLValue |
|
||||
TVO_CanBindToInOut);
|
||||
TVO_CanBindToLValue);
|
||||
addConstraint(ConstraintKind::BindParam, valueType, typeVar,
|
||||
getConstraintLocator(locator));
|
||||
OpenedParameterTypes.insert(std::make_pair(param, typeVar));
|
||||
@@ -1468,10 +1467,10 @@ resolveOverloadForDeclWithSpecialTypeCheckingSemantics(ConstraintSystem &CS,
|
||||
// be expressed in the type system currently.
|
||||
auto input = CS.createTypeVariable(
|
||||
CS.getConstraintLocator(locator, ConstraintLocator::FunctionArgument),
|
||||
TVO_CanBindToInOut);
|
||||
/*options*/0);
|
||||
auto output = CS.createTypeVariable(
|
||||
CS.getConstraintLocator(locator, ConstraintLocator::FunctionResult),
|
||||
TVO_CanBindToInOut);
|
||||
/*options*/0);
|
||||
|
||||
auto inputArg = TupleTypeElt(input, CS.getASTContext().getIdentifier("of"));
|
||||
auto inputTuple = TupleType::get(inputArg, CS.getASTContext());
|
||||
@@ -1488,16 +1487,16 @@ resolveOverloadForDeclWithSpecialTypeCheckingSemantics(ConstraintSystem &CS,
|
||||
// @escaping.
|
||||
auto noescapeClosure = CS.createTypeVariable(
|
||||
CS.getConstraintLocator(locator, ConstraintLocator::FunctionArgument),
|
||||
TVO_CanBindToInOut);
|
||||
/*options*/0);
|
||||
auto escapeClosure = CS.createTypeVariable(
|
||||
CS.getConstraintLocator(locator, ConstraintLocator::FunctionArgument),
|
||||
TVO_CanBindToInOut);
|
||||
/*options*/0);
|
||||
CS.addConstraint(ConstraintKind::EscapableFunctionOf,
|
||||
escapeClosure, noescapeClosure,
|
||||
CS.getConstraintLocator(locator, ConstraintLocator::RvalueAdjustment));
|
||||
auto result = CS.createTypeVariable(
|
||||
CS.getConstraintLocator(locator, ConstraintLocator::FunctionResult),
|
||||
TVO_CanBindToInOut);
|
||||
/*options*/0);
|
||||
auto bodyClosure = FunctionType::get(
|
||||
ParenType::get(CS.getASTContext(), escapeClosure), result,
|
||||
FunctionType::ExtInfo(FunctionType::Representation::Swift,
|
||||
@@ -1523,16 +1522,16 @@ resolveOverloadForDeclWithSpecialTypeCheckingSemantics(ConstraintSystem &CS,
|
||||
// existential type as its input.
|
||||
auto openedTy = CS.createTypeVariable(
|
||||
CS.getConstraintLocator(locator, ConstraintLocator::FunctionArgument),
|
||||
TVO_CanBindToInOut);
|
||||
/*options*/0);
|
||||
auto existentialTy = CS.createTypeVariable(
|
||||
CS.getConstraintLocator(locator, ConstraintLocator::FunctionArgument),
|
||||
TVO_CanBindToInOut);
|
||||
/*options*/0);
|
||||
CS.addConstraint(ConstraintKind::OpenedExistentialOf,
|
||||
openedTy, existentialTy,
|
||||
CS.getConstraintLocator(locator, ConstraintLocator::RvalueAdjustment));
|
||||
auto result = CS.createTypeVariable(
|
||||
CS.getConstraintLocator(locator, ConstraintLocator::FunctionResult),
|
||||
TVO_CanBindToInOut);
|
||||
/*options*/0);
|
||||
auto bodyClosure = FunctionType::get(
|
||||
ParenType::get(CS.getASTContext(), openedTy), result,
|
||||
FunctionType::ExtInfo(FunctionType::Representation::Swift,
|
||||
@@ -1630,7 +1629,7 @@ void ConstraintSystem::resolveOverload(ConstraintLocator *locator,
|
||||
if (choice.isImplicitlyUnwrappedValueOrReturnValue()) {
|
||||
// Build the disjunction to attempt binding both T? and T (or
|
||||
// function returning T? and function returning T).
|
||||
Type ty = createTypeVariable(locator, TVO_CanBindToInOut);
|
||||
Type ty = createTypeVariable(locator, /*options*/0);
|
||||
buildDisjunctionForImplicitlyUnwrappedOptional(ty, refType,
|
||||
locator);
|
||||
addConstraint(ConstraintKind::Bind, boundType,
|
||||
@@ -1660,7 +1659,7 @@ void ConstraintSystem::resolveOverload(ConstraintLocator *locator,
|
||||
// For our original type T -> U?? we will generate:
|
||||
// A disjunction V = { U?, U }
|
||||
// and a disjunction boundType = { T -> V?, T -> V }
|
||||
Type ty = createTypeVariable(locator, TVO_CanBindToInOut);
|
||||
Type ty = createTypeVariable(locator, /*options*/0);
|
||||
|
||||
buildDisjunctionForImplicitlyUnwrappedOptional(ty, optTy, locator);
|
||||
|
||||
@@ -1771,14 +1770,13 @@ void ConstraintSystem::resolveOverload(ConstraintLocator *locator,
|
||||
// the mutability of the base.
|
||||
auto keyPathIndexTy = createTypeVariable(
|
||||
getConstraintLocator(locator, ConstraintLocator::FunctionArgument),
|
||||
TVO_CanBindToInOut);
|
||||
/*options*/0);
|
||||
auto elementTy = createTypeVariable(
|
||||
getConstraintLocator(locator, ConstraintLocator::FunctionArgument),
|
||||
TVO_CanBindToLValue |
|
||||
TVO_CanBindToInOut);
|
||||
TVO_CanBindToLValue);
|
||||
auto elementObjTy = createTypeVariable(
|
||||
getConstraintLocator(locator, ConstraintLocator::FunctionArgument),
|
||||
TVO_CanBindToInOut);
|
||||
/*options*/0);
|
||||
addConstraint(ConstraintKind::Equal, elementTy, elementObjTy, locator);
|
||||
|
||||
// The element result is an lvalue or rvalue based on the key path class.
|
||||
|
||||
@@ -1995,9 +1995,7 @@ bool TypeChecker::typeCheckCompletionSequence(Expr *&expr, DeclContext *DC) {
|
||||
|
||||
// Add type variable for the code-completion expression.
|
||||
auto tvRHS =
|
||||
CS.createTypeVariable(CS.getConstraintLocator(CCE),
|
||||
TVO_CanBindToLValue |
|
||||
TVO_CanBindToInOut);
|
||||
CS.createTypeVariable(CS.getConstraintLocator(CCE), TVO_CanBindToLValue);
|
||||
CCE->setType(tvRHS);
|
||||
|
||||
if (auto generated = CS.generateConstraints(expr)) {
|
||||
@@ -2711,8 +2709,7 @@ static Type replaceArchetypesWithTypeVariables(ConstraintSystem &cs,
|
||||
return Type();
|
||||
|
||||
auto locator = cs.getConstraintLocator(nullptr);
|
||||
auto replacement = cs.createTypeVariable(locator,
|
||||
TVO_CanBindToInOut);
|
||||
auto replacement = cs.createTypeVariable(locator, /*options*/0);
|
||||
|
||||
if (auto superclass = archetypeType->getSuperclass()) {
|
||||
cs.addConstraint(ConstraintKind::Subtype, replacement,
|
||||
@@ -2729,8 +2726,7 @@ static Type replaceArchetypesWithTypeVariables(ConstraintSystem &cs,
|
||||
// FIXME: Remove this case
|
||||
assert(cast<GenericTypeParamType>(origType));
|
||||
auto locator = cs.getConstraintLocator(nullptr);
|
||||
auto replacement = cs.createTypeVariable(locator,
|
||||
TVO_CanBindToInOut);
|
||||
auto replacement = cs.createTypeVariable(locator, /*options*/0);
|
||||
types[origType] = replacement;
|
||||
return replacement;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user