Skip to content

Commit 8f29f76

Browse files
committed
Sema: Clean up some dead InOutType-related logic in typeCheckBinding()
1 parent 04ce7ab commit 8f29f76

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,31 +2356,29 @@ bool TypeChecker::typeCheckBinding(Pattern *&pattern, Expr *&initializer,
23562356
ConstraintLocator *Locator;
23572357

23582358
/// The type of the initializer.
2359-
llvm::PointerIntPair<Type, 1, bool> InitTypeAndInOut;
2359+
Type initType;
23602360

23612361
public:
23622362
explicit BindingListener(Pattern *&pattern, Expr *&initializer)
23632363
: pattern(pattern), initializer(initializer),
2364-
Locator(nullptr), InitTypeAndInOut(Type(), false) { }
2364+
Locator(nullptr) { }
23652365

2366-
Type getInitType() const { return InitTypeAndInOut.getPointer(); }
2367-
bool isInOut() const { return InitTypeAndInOut.getInt(); }
2366+
Type getInitType() const { return initType; }
23682367

23692368
bool builtConstraints(ConstraintSystem &cs, Expr *expr) override {
2369+
assert(!expr->isSemanticallyInOutExpr());
2370+
23702371
// Save the locator we're using for the expression.
23712372
Locator = cs.getConstraintLocator(expr);
23722373

23732374
// 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)
23772377
return true;
23782378

2379-
assert(!InitTypeAndInOut.getPointer()->is<InOutType>());
23802379
// Add a conversion constraint between the types.
23812380
cs.addConstraint(ConstraintKind::Conversion, cs.getType(expr),
2382-
InitTypeAndInOut.getPointer(), Locator,
2383-
/*isFavored*/true);
2381+
initType, Locator, /*isFavored*/true);
23842382

23852383
// The expression has been pre-checked; save it in case we fail later.
23862384
initializer = expr;
@@ -2389,25 +2387,21 @@ bool TypeChecker::typeCheckBinding(Pattern *&pattern, Expr *&initializer,
23892387

23902388
Expr *foundSolution(Solution &solution, Expr *expr) override {
23912389
// 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);
23962392

23972393
// Just keep going.
23982394
return expr;
23992395
}
24002396

24012397
Expr *appliedSolution(Solution &solution, Expr *expr) override {
24022398
// 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,
24052400
false /* ignoreTopLevelInjection */);
2406-
if (!expr) {
2401+
if (!expr)
24072402
return nullptr;
2408-
}
24092403

2410-
assert(solution.getConstraintSystem().getType(expr)->isEqual(InitTypeAndInOut.getPointer()));
2404+
assert(solution.getConstraintSystem().getType(expr)->isEqual(initType));
24112405

24122406
initializer = expr;
24132407
return expr;
@@ -2442,7 +2436,6 @@ bool TypeChecker::typeCheckBinding(Pattern *&pattern, Expr *&initializer,
24422436
// Type-check the initializer.
24432437
auto resultTy = typeCheckExpression(initializer, DC, contextualType,
24442438
contextualPurpose, flags, &listener);
2445-
assert(!listener.isInOut());
24462439

24472440
if (resultTy) {
24482441
TypeResolutionOptions options =

0 commit comments

Comments
 (0)