@@ -2413,79 +2413,14 @@ TypeChecker::getTypeOfCompletionOperator(DeclContext *DC, Expr *LHS,
2413
2413
bool TypeChecker::typeCheckBinding (Pattern *&pattern, Expr *&initializer,
2414
2414
DeclContext *DC,
2415
2415
Type patternType) {
2416
-
2417
- // / Type checking listener for pattern binding initializers.
2418
- class BindingListener : public ExprTypeCheckListener {
2419
- ASTContext &context;
2420
-
2421
- SolutionApplicationTarget target;
2422
-
2423
- // / The locator we're using.
2424
- ConstraintLocator *Locator;
2425
-
2426
- // / The variable to that has property wrappers that have been applied to the initializer expression.
2427
- VarDecl *wrappedVar = nullptr ;
2428
-
2429
- public:
2430
- explicit BindingListener (ASTContext &ctx, SolutionApplicationTarget target)
2431
- : context(ctx), target(target), Locator(nullptr ) {
2432
- wrappedVar = target.getInitializationWrappedVar ();
2433
- }
2434
-
2435
- bool builtConstraints (ConstraintSystem &cs, Expr *expr) override {
2436
- // The expression has been pre-checked; save it in case we fail later.
2437
- Locator = cs.getConstraintLocator (expr, LocatorPathElt::ContextualType ());
2438
- return false ;
2439
- }
2440
-
2441
- Expr *appliedSolution (Solution &solution, Expr *expr) override {
2442
- Type initType;
2443
- if (wrappedVar) {
2444
- initType = solution.getType (expr);
2445
- } else {
2446
- initType = solution.getType (target.getInitializationPattern ());
2447
- }
2448
-
2449
- {
2450
- // Figure out what type the constraints decided on.
2451
- auto ty = solution.simplifyType (initType);
2452
- initType = ty->getRValueType ()->reconstituteSugar (/* recursive =*/ false );
2453
- }
2454
-
2455
- // Convert the initializer to the type of the pattern.
2456
- expr = solution.coerceToType (expr, initType, Locator);
2457
- if (!expr)
2458
- return nullptr ;
2459
-
2460
- // Record the property wrapper type and note that the initializer has
2461
- // been subsumed by the backing property.
2462
- if (wrappedVar) {
2463
- wrappedVar->getParentPatternBinding ()->setInitializerSubsumed (0 );
2464
- context.setSideCachedPropertyWrapperBackingPropertyType (
2465
- wrappedVar, initType->mapTypeOutOfContext ());
2466
-
2467
- // Record the semantic initializer on the outermost property wrapper.
2468
- wrappedVar->getAttachedPropertyWrappers ().front ()
2469
- ->setSemanticInit (expr);
2470
- }
2471
-
2472
- return expr;
2473
- }
2474
- };
2475
-
2476
2416
auto &Context = DC->getASTContext ();
2477
2417
auto target = SolutionApplicationTarget::forInitialization (
2478
2418
initializer, DC, patternType, pattern);
2479
2419
initializer = target.getAsExpr ();
2480
2420
2481
- BindingListener listener (Context, target);
2482
- if (!initializer)
2483
- return true ;
2484
-
2485
2421
// Type-check the initializer.
2486
2422
bool unresolvedTypeExprs = false ;
2487
- auto resultTarget = typeCheckExpression (target, unresolvedTypeExprs,
2488
- None, &listener);
2423
+ auto resultTarget = typeCheckExpression (target, unresolvedTypeExprs);
2489
2424
2490
2425
if (resultTarget) {
2491
2426
initializer = resultTarget->getAsExpr ();
0 commit comments