@@ -985,8 +985,7 @@ namespace {
985
985
auto baseTy = CS.getType (base);
986
986
auto tv = CS.createTypeVariable (
987
987
CS.getConstraintLocator (expr, ConstraintLocator::Member),
988
- TVO_CanBindToLValue |
989
- TVO_CanBindToInOut);
988
+ TVO_CanBindToLValue);
990
989
CS.addValueMemberConstraint (baseTy, name, tv, CurDC, functionRefKind,
991
990
CS.getConstraintLocator (expr, ConstraintLocator::Member));
992
991
return tv;
@@ -1006,9 +1005,7 @@ namespace {
1006
1005
1007
1006
auto memberLocator =
1008
1007
CS.getConstraintLocator (expr, ConstraintLocator::Member);
1009
- auto tv = CS.createTypeVariable (memberLocator,
1010
- TVO_CanBindToLValue |
1011
- TVO_CanBindToInOut);
1008
+ auto tv = CS.createTypeVariable (memberLocator, TVO_CanBindToLValue);
1012
1009
1013
1010
OverloadChoice choice =
1014
1011
OverloadChoice (CS.getType (base), decl, functionRefKind);
@@ -1036,7 +1033,7 @@ namespace {
1036
1033
// I -> inout? O, where I and O are fresh type variables. The index
1037
1034
// expression must be convertible to I and the subscript expression
1038
1035
// itself has type inout? O, where O may or may not be an lvalue.
1039
- auto inputTv = CS.createTypeVariable (indexLocator, TVO_CanBindToInOut );
1036
+ auto inputTv = CS.createTypeVariable (indexLocator, /* options */ 0 );
1040
1037
1041
1038
// For an integer subscript expression on an array slice type, instead of
1042
1039
// introducing a new type variable we can easily obtain the element type.
@@ -1083,9 +1080,7 @@ namespace {
1083
1080
}
1084
1081
1085
1082
if (outputTy.isNull ()) {
1086
- outputTy = CS.createTypeVariable (resultLocator,
1087
- TVO_CanBindToLValue |
1088
- TVO_CanBindToInOut);
1083
+ outputTy = CS.createTypeVariable (resultLocator, TVO_CanBindToLValue);
1089
1084
} else {
1090
1085
// TODO: Generalize this for non-subscript-expr anchors, so that e.g.
1091
1086
// keypath lookup benefits from the peephole as well.
@@ -1174,8 +1169,7 @@ namespace {
1174
1169
1175
1170
1176
1171
auto tv = CS.createTypeVariable (CS.getConstraintLocator (expr),
1177
- TVO_PrefersSubtypeBinding |
1178
- TVO_CanBindToInOut);
1172
+ TVO_PrefersSubtypeBinding);
1179
1173
CS.addConstraint (ConstraintKind::LiteralConformsTo, tv,
1180
1174
protocol->getDeclaredType (),
1181
1175
CS.getConstraintLocator (expr));
@@ -1197,9 +1191,7 @@ namespace {
1197
1191
// The type of the expression must conform to the
1198
1192
// ExpressibleByStringInterpolation protocol.
1199
1193
auto locator = CS.getConstraintLocator (expr);
1200
- auto tv = CS.createTypeVariable (locator,
1201
- TVO_PrefersSubtypeBinding |
1202
- TVO_CanBindToInOut);
1194
+ auto tv = CS.createTypeVariable (locator, TVO_PrefersSubtypeBinding);
1203
1195
CS.addConstraint (ConstraintKind::LiteralConformsTo, tv,
1204
1196
interpolationProto->getDeclaredType (),
1205
1197
locator);
@@ -1244,8 +1236,7 @@ namespace {
1244
1236
}
1245
1237
1246
1238
auto tv = CS.createTypeVariable (CS.getConstraintLocator (expr),
1247
- TVO_PrefersSubtypeBinding |
1248
- TVO_CanBindToInOut);
1239
+ TVO_PrefersSubtypeBinding);
1249
1240
1250
1241
CS.addConstraint (ConstraintKind::LiteralConformsTo, tv,
1251
1242
protocol->getDeclaredType (),
@@ -1288,8 +1279,7 @@ namespace {
1288
1279
if (VD->hasInterfaceType () &&
1289
1280
VD->getInterfaceType ()->is <UnresolvedType>()) {
1290
1281
return CS.createTypeVariable (CS.getConstraintLocator (E),
1291
- TVO_CanBindToLValue |
1292
- TVO_CanBindToInOut);
1282
+ TVO_CanBindToLValue);
1293
1283
}
1294
1284
}
1295
1285
@@ -1375,9 +1365,7 @@ namespace {
1375
1365
// that will be equal to different types depending on which overload
1376
1366
// is selected.
1377
1367
auto locator = CS.getConstraintLocator (expr);
1378
- auto tv = CS.createTypeVariable (locator,
1379
- TVO_CanBindToLValue |
1380
- TVO_CanBindToInOut);
1368
+ auto tv = CS.createTypeVariable (locator, TVO_CanBindToLValue);
1381
1369
ArrayRef<ValueDecl*> decls = expr->getDecls ();
1382
1370
SmallVector<OverloadChoice, 4 > choices;
1383
1371
@@ -1408,8 +1396,7 @@ namespace {
1408
1396
// to help us determine which declaration the user meant to refer to.
1409
1397
// FIXME: Do we need to note that we're doing some kind of recovery?
1410
1398
return CS.createTypeVariable (CS.getConstraintLocator (expr),
1411
- TVO_CanBindToLValue |
1412
- TVO_CanBindToInOut);
1399
+ TVO_CanBindToLValue);
1413
1400
}
1414
1401
1415
1402
Type visitMemberRefExpr (MemberRefExpr *expr) {
@@ -1434,10 +1421,8 @@ namespace {
1434
1421
1435
1422
auto memberLocator
1436
1423
= CS.getConstraintLocator (expr, ConstraintLocator::UnresolvedMember);
1437
- auto baseTy = CS.createTypeVariable (baseLocator, TVO_CanBindToInOut);
1438
- auto memberTy = CS.createTypeVariable (memberLocator,
1439
- TVO_CanBindToLValue |
1440
- TVO_CanBindToInOut);
1424
+ auto baseTy = CS.createTypeVariable (baseLocator, /* options*/ 0 );
1425
+ auto memberTy = CS.createTypeVariable (memberLocator, TVO_CanBindToLValue);
1441
1426
1442
1427
// An unresolved member expression '.member' is modeled as a value member
1443
1428
// constraint
@@ -1458,7 +1443,7 @@ namespace {
1458
1443
// need to include everything else in the world?
1459
1444
auto outputTy = CS.createTypeVariable (
1460
1445
CS.getConstraintLocator (expr, ConstraintLocator::FunctionResult),
1461
- TVO_CanBindToInOut );
1446
+ /* options */ 0 );
1462
1447
CS.addConstraint (ConstraintKind::Conversion, outputTy, baseTy,
1463
1448
CS.getConstraintLocator (expr, ConstraintLocator::RvalueAdjustment));
1464
1449
@@ -1477,9 +1462,7 @@ namespace {
1477
1462
1478
1463
// The member type also needs to be convertible to the context type, which
1479
1464
// preserves lvalue-ness.
1480
- auto resultTy = CS.createTypeVariable (memberLocator,
1481
- TVO_CanBindToLValue |
1482
- TVO_CanBindToInOut);
1465
+ auto resultTy = CS.createTypeVariable (memberLocator, TVO_CanBindToLValue);
1483
1466
CS.addConstraint (ConstraintKind::Conversion, memberTy, resultTy,
1484
1467
memberLocator);
1485
1468
CS.addConstraint (ConstraintKind::Equal, resultTy, baseTy,
@@ -1513,10 +1496,9 @@ namespace {
1513
1496
auto argsTy = CS.createTypeVariable (
1514
1497
CS.getConstraintLocator (expr),
1515
1498
TVO_CanBindToLValue |
1516
- TVO_PrefersSubtypeBinding |
1517
- TVO_CanBindToInOut);
1499
+ TVO_PrefersSubtypeBinding);
1518
1500
auto resultTy = CS.createTypeVariable (CS.getConstraintLocator (expr),
1519
- TVO_CanBindToInOut );
1501
+ /* options */ 0 );
1520
1502
auto methodTy = FunctionType::get (argsTy, resultTy);
1521
1503
CS.addValueMemberConstraint (baseTy, expr->getName (),
1522
1504
methodTy, CurDC, expr->getFunctionRefKind (),
@@ -1620,8 +1602,7 @@ namespace {
1620
1602
1621
1603
Type visitOptionalTryExpr (OptionalTryExpr *expr) {
1622
1604
auto valueTy = CS.createTypeVariable (CS.getConstraintLocator (expr),
1623
- TVO_PrefersSubtypeBinding |
1624
- TVO_CanBindToInOut);
1605
+ TVO_PrefersSubtypeBinding);
1625
1606
1626
1607
Type optTy = getOptionalType (expr->getSubExpr ()->getLoc (), valueTy);
1627
1608
if (!optTy)
@@ -1722,9 +1703,7 @@ namespace {
1722
1703
return contextualArrayType;
1723
1704
}
1724
1705
1725
- auto arrayTy = CS.createTypeVariable (locator,
1726
- TVO_PrefersSubtypeBinding |
1727
- TVO_CanBindToInOut);
1706
+ auto arrayTy = CS.createTypeVariable (locator, TVO_PrefersSubtypeBinding);
1728
1707
1729
1708
// The array must be an array literal type.
1730
1709
CS.addConstraint (ConstraintKind::LiteralConformsTo, arrayTy,
@@ -1820,8 +1799,7 @@ namespace {
1820
1799
}
1821
1800
1822
1801
auto dictionaryTy = CS.createTypeVariable (locator,
1823
- TVO_PrefersSubtypeBinding |
1824
- TVO_CanBindToInOut);
1802
+ TVO_PrefersSubtypeBinding);
1825
1803
1826
1804
// The dictionary must be a dictionary literal type.
1827
1805
CS.addConstraint (ConstraintKind::LiteralConformsTo, dictionaryTy,
@@ -1997,7 +1975,7 @@ namespace {
1997
1975
}
1998
1976
1999
1977
return CS.createTypeVariable (CS.getConstraintLocator (locator),
2000
- TVO_CanBindToInOut );
1978
+ /* options */ 0 );
2001
1979
}
2002
1980
2003
1981
case PatternKind::Named: {
@@ -2314,7 +2292,7 @@ namespace {
2314
2292
2315
2293
// If no return type was specified, create a fresh type
2316
2294
// variable for it.
2317
- funcTy = CS.createTypeVariable (locator, TVO_CanBindToInOut );
2295
+ funcTy = CS.createTypeVariable (locator, /* options */ 0 );
2318
2296
2319
2297
// Allow it to default to () if there are no return statements.
2320
2298
if (closureHasNoResult (expr)) {
@@ -2363,7 +2341,7 @@ namespace {
2363
2341
2364
2342
Type visitDynamicTypeExpr (DynamicTypeExpr *expr) {
2365
2343
auto tv = CS.createTypeVariable (CS.getConstraintLocator (expr),
2366
- TVO_CanBindToInOut );
2344
+ /* options */ 0 );
2367
2345
CS.addConstraint (ConstraintKind::DynamicTypeOf, tv,
2368
2346
CS.getType (expr->getBase ()),
2369
2347
CS.getConstraintLocator (expr, ConstraintLocator::RvalueAdjustment));
@@ -2441,7 +2419,7 @@ namespace {
2441
2419
if (outputTy.isNull ()) {
2442
2420
outputTy = CS.createTypeVariable (
2443
2421
CS.getConstraintLocator (expr, ConstraintLocator::FunctionResult),
2444
- TVO_CanBindToInOut );
2422
+ /* options */ 0 );
2445
2423
} else {
2446
2424
// Since we know what the output type is, we can set it as the favored
2447
2425
// type of this expression.
@@ -2694,9 +2672,7 @@ namespace {
2694
2672
// just plop an open type variable here.
2695
2673
2696
2674
auto locator = CS.getConstraintLocator (expr);
2697
- auto typeVar = CS.createTypeVariable (locator,
2698
- TVO_CanBindToLValue |
2699
- TVO_CanBindToInOut);
2675
+ auto typeVar = CS.createTypeVariable (locator, TVO_CanBindToLValue);
2700
2676
return typeVar;
2701
2677
}
2702
2678
@@ -2719,8 +2695,7 @@ namespace {
2719
2695
2720
2696
auto objectTy = CS.createTypeVariable (locator,
2721
2697
TVO_PrefersSubtypeBinding |
2722
- TVO_CanBindToLValue |
2723
- TVO_CanBindToInOut);
2698
+ TVO_CanBindToLValue);
2724
2699
2725
2700
// The result is the object type of the optional subexpression.
2726
2701
CS.addConstraint (ConstraintKind::OptionalObject,
@@ -2735,8 +2710,7 @@ namespace {
2735
2710
// optional types, e.g. T? over T??; otherwise we don't really
2736
2711
// have a preference.
2737
2712
auto valueTy = CS.createTypeVariable (CS.getConstraintLocator (expr),
2738
- TVO_PrefersSubtypeBinding |
2739
- TVO_CanBindToInOut);
2713
+ TVO_PrefersSubtypeBinding);
2740
2714
2741
2715
Type optTy = getOptionalType (expr->getSubExpr ()->getLoc (), valueTy);
2742
2716
if (!optTy)
@@ -2754,8 +2728,7 @@ namespace {
2754
2728
2755
2729
auto objectTy = CS.createTypeVariable (locator,
2756
2730
TVO_PrefersSubtypeBinding |
2757
- TVO_CanBindToLValue |
2758
- TVO_CanBindToInOut);
2731
+ TVO_CanBindToLValue);
2759
2732
2760
2733
// The result is the object type of the optional subexpression.
2761
2734
CS.addConstraint (ConstraintKind::OptionalObject,
@@ -2796,7 +2769,7 @@ namespace {
2796
2769
auto &placeholderTy
2797
2770
= editorPlaceholderVariables[currentEditorPlaceholderVariable];
2798
2771
if (!placeholderTy) {
2799
- placeholderTy = CS.createTypeVariable (locator, TVO_CanBindToInOut );
2772
+ placeholderTy = CS.createTypeVariable (locator, /* options */ 0 );
2800
2773
2801
2774
CS.addConstraint (ConstraintKind::Defaultable,
2802
2775
placeholderTy,
@@ -2852,7 +2825,7 @@ namespace {
2852
2825
// For native key paths, traverse the key path components to set up
2853
2826
// appropriate type relationships at each level.
2854
2827
auto locator = CS.getConstraintLocator (E);
2855
- Type root = CS.createTypeVariable (locator, TVO_CanBindToInOut );
2828
+ Type root = CS.createTypeVariable (locator, /* options */ 0 );
2856
2829
2857
2830
// If a root type was explicitly given, then resolve it now.
2858
2831
if (auto rootRepr = E->getRootType ()) {
@@ -2878,9 +2851,7 @@ namespace {
2878
2851
// This should only appear in resolved ASTs, but we may need to
2879
2852
// re-type-check the constraints during failure diagnosis.
2880
2853
case KeyPathExpr::Component::Kind::Property: {
2881
- auto memberTy = CS.createTypeVariable (locator,
2882
- TVO_CanBindToLValue |
2883
- TVO_CanBindToInOut);
2854
+ auto memberTy = CS.createTypeVariable (locator, TVO_CanBindToLValue);
2884
2855
auto lookupName = kind == KeyPathExpr::Component::Kind::UnresolvedProperty
2885
2856
? component.getUnresolvedDeclName ()
2886
2857
: component.getDeclRef ().getDecl ()->getFullName ();
@@ -2924,8 +2895,7 @@ namespace {
2924
2895
}
2925
2896
case KeyPathExpr::Component::Kind::OptionalForce: {
2926
2897
auto optionalObjTy = CS.createTypeVariable (locator,
2927
- TVO_CanBindToLValue |
2928
- TVO_CanBindToInOut);
2898
+ TVO_CanBindToLValue);
2929
2899
2930
2900
CS.addConstraint (ConstraintKind::OptionalObject, base, optionalObjTy,
2931
2901
locator);
@@ -2946,14 +2916,14 @@ namespace {
2946
2916
// If there was an optional chaining component, the end result must be
2947
2917
// optional.
2948
2918
if (didOptionalChain) {
2949
- auto objTy = CS.createTypeVariable (locator, TVO_CanBindToInOut );
2919
+ auto objTy = CS.createTypeVariable (locator, /* options */ 0 );
2950
2920
auto optTy = OptionalType::get (objTy);
2951
2921
CS.addConstraint (ConstraintKind::Conversion, base, optTy,
2952
2922
locator);
2953
2923
base = optTy;
2954
2924
}
2955
2925
2956
- auto rvalueBase = CS.createTypeVariable (locator, TVO_CanBindToInOut );
2926
+ auto rvalueBase = CS.createTypeVariable (locator, /* options */ 0 );
2957
2927
CS.addConstraint (ConstraintKind::Equal, base, rvalueBase, locator);
2958
2928
2959
2929
// The result is a KeyPath from the root to the end component.
@@ -2965,7 +2935,7 @@ namespace {
2965
2935
// The type of key path depends on the overloads chosen for the key
2966
2936
// path components.
2967
2937
kpTy = CS.createTypeVariable (CS.getConstraintLocator (E),
2968
- TVO_CanBindToInOut );
2938
+ /* options */ 0 );
2969
2939
CS.addKeyPathConstraint (kpTy, root, rvalueBase,
2970
2940
CS.getConstraintLocator (E));
2971
2941
}
@@ -3433,8 +3403,7 @@ class InferUnresolvedMemberConstraintGenerator : public ConstraintGenerator {
3433
3403
TypeVariableType *createFreeTypeVariableType (Expr *E) {
3434
3404
auto &CS = getConstraintSystem ();
3435
3405
return CS.createTypeVariable (CS.getConstraintLocator (nullptr ),
3436
- TVO_CanBindToLValue |
3437
- TVO_CanBindToInOut);
3406
+ TVO_CanBindToLValue);
3438
3407
}
3439
3408
3440
3409
public:
@@ -3664,9 +3633,7 @@ swift::resolveValueMember(DeclContext &DC, Type BaseTy, DeclName Name) {
3664
3633
3665
3634
// Try to figure out the best overload.
3666
3635
ConstraintLocator *Locator = CS.getConstraintLocator (nullptr );
3667
- TypeVariableType *TV = CS.createTypeVariable (Locator,
3668
- TVO_CanBindToLValue |
3669
- TVO_CanBindToInOut);
3636
+ TypeVariableType *TV = CS.createTypeVariable (Locator, TVO_CanBindToLValue);
3670
3637
CS.addOverloadSet (TV, LookupResult.ViableCandidates , &DC, Locator);
3671
3638
Optional<Solution> OpSolution = CS.solveSingle ();
3672
3639
ValueDecl *Selected = nullptr ;
0 commit comments