@@ -2356,31 +2356,29 @@ bool TypeChecker::typeCheckBinding(Pattern *&pattern, Expr *&initializer,
2356
2356
ConstraintLocator *Locator;
2357
2357
2358
2358
// / The type of the initializer.
2359
- llvm::PointerIntPair< Type, 1 , bool > InitTypeAndInOut ;
2359
+ Type initType ;
2360
2360
2361
2361
public:
2362
2362
explicit BindingListener (Pattern *&pattern, Expr *&initializer)
2363
2363
: pattern(pattern), initializer(initializer),
2364
- Locator(nullptr ), InitTypeAndInOut(Type(), false) { }
2364
+ Locator(nullptr ) { }
2365
2365
2366
- Type getInitType () const { return InitTypeAndInOut.getPointer (); }
2367
- bool isInOut () const { return InitTypeAndInOut.getInt (); }
2366
+ Type getInitType () const { return initType; }
2368
2367
2369
2368
bool builtConstraints (ConstraintSystem &cs, Expr *expr) override {
2369
+ assert (!expr->isSemanticallyInOutExpr ());
2370
+
2370
2371
// Save the locator we're using for the expression.
2371
2372
Locator = cs.getConstraintLocator (expr);
2372
2373
2373
2374
// Collect constraints from the pattern.
2374
- InitTypeAndInOut.setPointer (cs.generateConstraints (pattern, Locator));
2375
- InitTypeAndInOut.setInt (expr->isSemanticallyInOutExpr ());
2376
- if (!InitTypeAndInOut.getPointer ())
2375
+ initType = cs.generateConstraints (pattern, Locator);
2376
+ if (!initType)
2377
2377
return true ;
2378
2378
2379
- assert (!InitTypeAndInOut.getPointer ()->is <InOutType>());
2380
2379
// Add a conversion constraint between the types.
2381
2380
cs.addConstraint (ConstraintKind::Conversion, cs.getType (expr),
2382
- InitTypeAndInOut.getPointer (), Locator,
2383
- /* isFavored*/ true );
2381
+ initType, Locator, /* isFavored*/ true );
2384
2382
2385
2383
// The expression has been pre-checked; save it in case we fail later.
2386
2384
initializer = expr;
@@ -2389,25 +2387,21 @@ bool TypeChecker::typeCheckBinding(Pattern *&pattern, Expr *&initializer,
2389
2387
2390
2388
Expr *foundSolution (Solution &solution, Expr *expr) override {
2391
2389
// Figure out what type the constraints decided on.
2392
- auto ty = solution.simplifyType (InitTypeAndInOut.getPointer ());
2393
- InitTypeAndInOut.setPointer (
2394
- ty->getRValueType ()->reconstituteSugar (/* recursive =*/ false ));
2395
- InitTypeAndInOut.setInt (expr->isSemanticallyInOutExpr ());
2390
+ auto ty = solution.simplifyType (initType);
2391
+ initType = ty->getRValueType ()->reconstituteSugar (/* recursive =*/ false );
2396
2392
2397
2393
// Just keep going.
2398
2394
return expr;
2399
2395
}
2400
2396
2401
2397
Expr *appliedSolution (Solution &solution, Expr *expr) override {
2402
2398
// Convert the initializer to the type of the pattern.
2403
- // ignoreTopLevelInjection = Binding->isConditional()
2404
- expr = solution.coerceToType (expr, InitTypeAndInOut.getPointer (), Locator,
2399
+ expr = solution.coerceToType (expr, initType, Locator,
2405
2400
false /* ignoreTopLevelInjection */ );
2406
- if (!expr) {
2401
+ if (!expr)
2407
2402
return nullptr ;
2408
- }
2409
2403
2410
- assert (solution.getConstraintSystem ().getType (expr)->isEqual (InitTypeAndInOut. getPointer () ));
2404
+ assert (solution.getConstraintSystem ().getType (expr)->isEqual (initType ));
2411
2405
2412
2406
initializer = expr;
2413
2407
return expr;
@@ -2442,7 +2436,6 @@ bool TypeChecker::typeCheckBinding(Pattern *&pattern, Expr *&initializer,
2442
2436
// Type-check the initializer.
2443
2437
auto resultTy = typeCheckExpression (initializer, DC, contextualType,
2444
2438
contextualPurpose, flags, &listener);
2445
- assert (!listener.isInOut ());
2446
2439
2447
2440
if (resultTy) {
2448
2441
TypeResolutionOptions options =
0 commit comments